C#中如何调用外部exe文件,并关闭自身

privatevoidbtnFinish_Click(objectsender,EventArgse){stringStartFile=Application.Start... private void btnFinish_Click(object sender, EventArgs e)
{
string StartFile = Application.StartupPath + "\\csed.exe";
try
{
Process proc = Process.Start(StartFile);
if (proc != null)
{
proc.WaitForExit(3000);
if (proc.HasExited)
{
MessageBox.Show(String.Format("外部程序 {0} 已经退出!", StartFile), this.Text,
MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
proc.Kill();
MessageBox.Show(String.Format("外部程序 {0} 被强行终止!", StartFile), this.Text,
MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
}
}
catch (ArgumentException ex)
{
MessageBox.Show(ex.Message, this.Text,
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
打开界面一闪而过,而外部csed.exe程序也没有打开
展开
 我来答
阳光的雷咩咩
2016-11-22 · TA获得超过1.4万个赞
知道大有可为答主
回答量:2.3万
采纳率:66%
帮助的人:7554万
展开全部
Process proc = Process.Start(StartFile);

有这句就够了,后面判断那么多干嘛?
更多追问追答
追问
那关闭现在的程序呢,打开外部调用这句就够了,关闭程序呢?
追答
问题是你贴的那么多代码没有一句是关闭自身的啊
本回答被提问者采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式