1、調(diào)用系統(tǒng)dll使用其提供的方法。
引用的dll,
[DllImport("kernel32.dll")]
public static extern int WinExec(string exeName, int operType);
調(diào)用,WinExec(@"路徑/exe的文件名", 參數(shù));operType參數(shù)如下
0: 隱藏, 并且任務(wù)欄也沒有最小化圖標(biāo)
1: 用最近的大小和位置顯示, 激活
2: 最小化, 激活
3: 最大化, 激活
4: 用最近的大小和位置顯示, 不激活
5: 同 1
6: 最小化, 不激活
7: 同 3
8: 同 3
9: 同 1
10: 同 1
最常見的ProcessStartInfo啟動(dòng)
ProcessStartInfo info = new ProcessStartInfo();
info.FileName = @"路徑/exe的文件名";
info.Arguments = "";
info.WindowStyle = ProcessWindowStyle.Minimized;
Process pro = Process.Start(info);
pro.WaitForExit();
3、結(jié)束啟動(dòng)的exe的進(jìn)程
Process[] allProgresse = System.Diagnostics.Process.GetProcessesByName("exe的進(jìn)程名");
foreach (Process closeProgress in allProgresse)
{
if (closeProgress.ProcessName.Equals("exe的進(jìn)程名"))
{
closeProgress.Kill();
closeProgress.WaitForExit();
break;
}
}