Reputation: 1
I have written a windows service to launch a sample windows application. Once the service loads it should start the application but in my case even though service starts it is not able to launch my application.
Below is the code:
protected override void OnStart(string[] args)
{
this.WriteToFile("Simple Service started {0}");
Process.Start("D:\\demo.exe");
this.WriteToFile("Simple Service ended {0}");
}
Upvotes: 0
Views: 1685
Reputation: 1605
It might be your service running with System.ServiceProcess.ServiceAccount.LocalSystem
account
Goto your ServiceInstaller.cs file
Goto InitializeComponent() method
Please change below line as per your code
this.serviceProcessInstaller.Account = System.ServiceProcess.ServiceAccount.User
NOTE: It will ask windows login id / password while service installation.
please read this wonderfule artical of MSDN
Upvotes: 1
Reputation: 58
ProcessStartInfo pinfo = new ProcessStartInfo("D:\\demo.exe");
pinfo.Verb = "runas";
Process.Start(pinfo);
Upvotes: 0