C# – Process.Start does not work when called from windows service

cnetprocessservice

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?

Best Answer

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.