English 中文(简体)
Why when running a program through a service, is the program not actually shown?
原标题:

When running a program, such as notepad, as a service do you not see the program visually? I see notepad running in the task manager but I can t actually see its instance running. Why is this?

问题回答

Services are meant as background applications, not foreground applications. Generally they run without direct user input or with user input through IPC (often providing a centralized point for multiple applications to communicate).

It s not common to setup any applications to just run as a service. Applications that run as a service are generally specifically engineered to do so because they perform certain tasks and may want to always be running to perform such tasks.

An application actually needs to support running as a service - typically it is done by recognizing the "service" command line key. Some applications will recognize the absence of the "service" key and either do nothing or show a warning.

When an application is started "as a service" it usually means that it has to work continuously in background and there s a chance that no user is currently logged on. That s why it should not expect any user input and therefore doesn t show the window.

Adding on @Quintin Robinson s answer, the reason why they doesn t show up on task manager is because they are (usually) run from an umbrella process.

To give you a better picture, download and run Microsoft s Process Explorer, then hold your mouse over one of the "svchost.exe" process running.

You should see some of the services that are running under it.

All user interaction in Windows takes place via Windowstations. By default, Windows services "interact" with a non-interactive station. It s not the station you re connected to, so you don t see any output.

You can change this behavior by changing the service properties, and enabling "Allow service to interact with desktop".

You can read more about this here.

Applications that run as a service (or that are launched by other applications that run as a service) by default run on a separate desktop that cannot interact with the desktop you see.

If you want to be able to interact with a service, you have set the service properties accordingly.

That being said, what you re seeing with Notepad almost certainly has nothing to do with services.





相关问题
Why running a service as Local System is bad on windows?

I am trying to find out the difference between difference service account types. I tumbled upon this question. The answer was because it has powerful access to local resources, and Network Service ...

Programmatically detect Windows cluster configuration?

Does anyone know how to programatically detect that a Windows server is part of a cluster? Further, is it possible to detect that the server is the active or passive node? [Edit] And detect it from ...

get file icon for Outlook appointment (.msg)

I ve read Get File Icon used by Shell and the other similar posts - and already use SHFileInfo to get the associated icon for any given extension, and that works great. However, Outlook uses ".msg" ...

Identifying idle state on a windows machine

I know about the GetLastInputInfo method but that would only give me the duration since last user input - keyboard or mouse. If a user input was last received 10 minutes ago, that wouldn t mean the ...

Terminating a thread gracefully not using TerminateThread()

My application creates a thread and that runs in the background all the time. I can only terminate the thread manually, not from within the thread callback function. At the moment I am using ...

热门标签