C#
[c#] Start a new process and Killing the current process (A프로그렘에서 B띄우기)
요지
2017. 7. 18. 14:09
Start a new process and Killing the current process
Q. A프로그램에서 A프로그램을 죽이고 B프로그램을 실행하고싶다
A.
이렇게처음에 짠코드를
//Start the BT Setup Process
ProcessStartInfo startInfo = new ProcessStartInfo(@"C:\TEST\B.exe");
Process.Start(startInfo);
//Terminate the FSA
Process[] myProcess = Process.GetProcessesByName(Process.GetCurrentProcess().ProcessName);
foreach (Process process in myProcess)
{
process.CloseMainWindow();
//all the windows messages has to be processed in the msg queue
//hence call to Application DoEvents forces the MSG
Application.DoEvents();
}
이렇게 변경해주었다.
Process.Start("A.exe");
Process.GetCurrentProcess().Kill(); // or Application.Exit(); or anything else