求c#语言中执行指定exe程序的代码语句
在c#中如何执行指定exe程序比如要想执行D盘下一个名叫abc.exe的程序那么在c#的代码中怎么写怎么用呢最好能帮我写个完整的程序代码要不然怕我不会呵呵...
在c#中如何执行指定exe程序 比如要想执行D盘下一个名叫abc.exe的程序 那么在c#的代码中怎么写 怎么用呢 最好能帮我写个完整的程序代码 要不然怕我不会 呵呵
展开
2个回答
2014-01-04
展开全部
/// <summary>
//author:qlb //date:9/25/2009//<para name="filename">执行程序名:如:QQ.exe</para> /// </summary>private void startup(string filename)
{ string exe_path = Application.StartupPath;// @"C:\Program Files\Tencent\QQ\";
System.Diagnostics.Process process = new System.Diagnostics.Process();
process.StartInfo.FileName = filename;
process.StartInfo.WorkingDirectory = exe_path;
process.StartInfo.CreateNoWindow = true;
try
{ try
{
process.Start();
if (process.HasExited)
{
//MessageBox.Show("complete"); }
}
catch (Exception cc) { }
System.Diagnostics.Process[] myProcesses = System.Diagnostics.Process.GetProcesses(); //foreach (System.Diagnostics.Process myProcess in myProcesses)
//{
// if ("christmas.vshost" == myProcess.ProcessName || "christmas" == myProcess.ProcessName)
// {
// myProcess.Kill();
// }
//}
}
catch (Exception cc) { MessageBox.Show(cc.Message); MessageBox.Show("很抱歉,暂是无法正常运行请手动运行程序!"); }
}
//author:qlb //date:9/25/2009//<para name="filename">执行程序名:如:QQ.exe</para> /// </summary>private void startup(string filename)
{ string exe_path = Application.StartupPath;// @"C:\Program Files\Tencent\QQ\";
System.Diagnostics.Process process = new System.Diagnostics.Process();
process.StartInfo.FileName = filename;
process.StartInfo.WorkingDirectory = exe_path;
process.StartInfo.CreateNoWindow = true;
try
{ try
{
process.Start();
if (process.HasExited)
{
//MessageBox.Show("complete"); }
}
catch (Exception cc) { }
System.Diagnostics.Process[] myProcesses = System.Diagnostics.Process.GetProcesses(); //foreach (System.Diagnostics.Process myProcess in myProcesses)
//{
// if ("christmas.vshost" == myProcess.ProcessName || "christmas" == myProcess.ProcessName)
// {
// myProcess.Kill();
// }
//}
}
catch (Exception cc) { MessageBox.Show(cc.Message); MessageBox.Show("很抱歉,暂是无法正常运行请手动运行程序!"); }
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2014-01-04
展开全部
这样执行Process.Start(@"D:\Program Files\Thunder Network\Thunder\Program\Thunder.exe");
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询