Tuesday, April 21, 2009

C# - Run a Process (Run an EXE)

CodeProject: Windows Services Can Install Themselves. :

Process myProcess = new Process();
string path = @'C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727';
myProcess.StartInfo.FileName = path + '\\InstallUtil.exe';
myProcess.StartInfo.Arguments = @'/u C:\Service1\Service1.exe';
myProcess.StartInfo.CreateNoWindow = true;
myProcess.Start();

myProcess.WaitForExit(60000);
if (!myProcess.HasExited)
myProcess.Kill();
myProcess.Close();

No comments:

Post a Comment