2010-09-30 157 views
1

是否可以使用其他應用程序關閉正在運行的應用程序?關閉窗口應用程序

我已經執行APP1.exeAPP1_UNIN.exe,我會那APP1_UNIN.exe殺死運行APP1.exe並將其卸載。 這可能嗎?

回答

1

要卸載應用程序,你就可以開始一個新的進程和調用msiexec.exe,並在command line您可以指定卸載什麼:

ProcessStartInfo psi; 
//take your choice of which you want to use: 
psi = new ProcessStartInfo("msiexec.exe", string.Format("/x {0}", "path of my msi")); 
psi = new ProcessStartInfo("msiexec.exe", string.Format("/x /n {{{0}}}", "my product code")); 
Process p = new Process(); 
p.StartInfo = psi; 
p.Start(); 
1

至少要殺掉正在運行的進程,你可以這樣做:

Process[] processes = Process.GetProcesses(); 
foreach (Process process in processes) { 
    if (process.ProcessName == "APP1.exe") { 
    try { 
     process.Kill(); 
     break; 
     } catch (Exception) { 
     //handle any exception here 
     } 
    } 
    } 
} 

關於卸載它,我不知道。

0

對於關閉,你可以通過殺死它的過程來完成。 System.Diagnostics.Process

0

是使用System.Diagnostics程序

你可以得到處理,並終止該進程。

相關問題