Executing shell command in windows services

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,
I am a newbie in this area. I would like to know whether is it possible to
execute shell command in windows service. I had install a program in the
server which i would like it to be executed using windows services. Is it
possible. If yes, how?
Thanks
 
Hi,
below is my code in the onStart function:
protected override void OnStart(string[] args)
{
file = new StreamWriter( new FileStream("c:\\ServiceTest.log",
System.IO.FileMode.Append ) );
this.file.WriteLine("Starting Service");
this.file.Flush();

System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.EnableRaisingEvents=false;
proc.StartInfo.FileName="notepad.exe";
proc.Start();
proc.WaitForExit();

// TODO: Add code here to start your service.
}
However, its still failed to load, any idea?
thanks in advance.
 
Back
Top