Click here to Skip to main content
15,891,513 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I wanted to call the external exe from windows service in windows 10. But when I install the service it does not work. To run the service I need to change the logon properties for that service. But I don't want to make any changes after installation of service. It should run as it is.

What I have tried:

Tried various examples given on blogs but no luck.
Posted
Updated 3-Jan-17 21:44pm

Based on your description the executable you're trying to run, needs privileges that are not granted to the account you're using to run the service. As this is part of Windows security system, you can't change the behaviour.

For example if the executable to run needs access to a network path and you're running the service using a local account, then the started executable uses the local account and necessarily cannot access the network resources.

If you don't want to change the service account then try starting the executable using different, explicitly specified credentials. You can define the account to use by defining them in ProcessStartInfo Class (System.Diagnostics)[^]
 
Share this answer
 
A windows service runs in session 0 which is isolated from any user session and thus has no screen attached to it. Any application with a GUI started from a service will just hang somewhere in the background but never become visible to a user.
 
Share this answer
 
Mike, thanks for this valuable information. I have tried below code but still no luck.

void OpenWithStartInfo()
{
    ProcessStartInfo startInfo = new ProcessStartInfo("IExplore.exe");
    startInfo.WindowStyle = ProcessWindowStyle.Minimized;

    Process.Start(startInfo);

    startInfo.Arguments = "www.northwindtraders.com";

    Process.Start(startInfo);
}
 
Share this answer
 
Comments
F-ES Sitecore 4-Jan-17 4:24am    
The service has no access to the user's desktop, it can't launch desktop applications like IE. What if no-one is logged in at all, what do you expect to happen then?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900