On Windows 8 I am running a windows service. This service is supposed to start a program by
Process.Start(exePath);
But the process exits immediately - even first line in the Main procedure is not executed. Before, when running the same process in same service on Windows 7, everything worked fine.
How can I make it work again? How to properly start a process from a windows service?
Windows Services cannot start additional applications because they are not running in the context of any particular user. Unlike regular Windows applications, services are now run in an isolated session and are prohibited from interacting with a user or the desktop. This leaves no place for the application to be run.
Start another application using your . NET code As a . NET method, Start has a series of overloads, which are different sets of parameters that determine exactly what the method does. The overloads let you specify just about any set of parameters that you might want to pass to another process when it starts.
Found the solution. Process has to be started like this:
ProcessStartInfo info = new ProcessStartInfo(exePath);
info.CreateNoWindow = true;
info.UseShellExecute = false;
Process.Start(info);
For some reason there are problems with priviledges when creating a shell window in the background of the SYSTEM.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With