Click here to Skip to main content
15,887,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a C# service with framework 4, it runs an external application using process.start, but it starts on the background, i install the service using
InstallUtil.exe -u Service.exe
from a command prompt running as administrator
here is the code:
Process.Start("path\to\application.exe");

These questionings are bugging me the most:
Does the application start on the background because i'm using a command prompt with administrative privileges?
Or because of the scope of the service (which is LocalSystem)?
Or even because the framework i'm using?
What i want is the application to be visible, what can i do?, what am i doing wrong?

What I have tried:

I tried this code to make the application visible, but it doesn't work (it starts on the background):
var processPath = ConfigurationManager.AppSettings["path"];
var process = new Process();
process.StartInfo = new ProcessStartInfo(processPath);
process.StartInfo.Verb = "Open";
process.StartInfo.WindowStyle = ProcessWindowStyle.Normal;
process.StartInfo.WorkingDirectory = Path.GetDirectoryName(processPath);
process.Start();

I even tried the option "Allow service to interact with desktop"
Posted
Updated 13-Apr-18 20:23pm
v2

None of the above.

All services run under a completely different desktop from the one you can see after you log in. Any application that the service launches will also show up on that service desktop.

Services can no longer interact with the users desktop like you could do in Windows XP.

For security reasons, you cannot see the services desktop at all. So any UI that a stupidly written service puts up or any UI that an application launched by a service puts up will never be seen by the user logged in at the console.
 
Share this answer
 
As Dave has said, services cannot interact directly with the user at all: this is because services can run on a machine that doesn't have a user logged in at all, so there is no way to interact with them.

The only way to communicate between a service and a user, is to run an application in the user space which talks to the service - that cannot be started from the service side, it can only be started post user login as a user process.
 
Share this answer
 

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