Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to launch a GUI program in a Windows service?

When I run a service as LocalSystem account, I can use following codes to launch a GUI program under current login account:

WTSGetActiveConsoleSessionId->WTSQueryUserToken->CreateProcessAsUser

However, when I run the service as my personal account, the GUI program will NOT show up. I can see it in task manager though.

What should I do to launch the GUI program when the service is running under my personal account?

like image 241
trudger Avatar asked Jun 04 '09 03:06

trudger


People also ask

How can a Windows service execute a GUI application?

The service communicates with the GUI application to tell it when to display the GUI. The application communicates the results of the user interaction back to the service so that the service can take the appropriate action.

Can Windows service have GUI?

Windows services cannot have GUIs, so you will need to either get rid of the GUI or separate your application into two pieces - a service with no UI, and a "controller" application.


1 Answers

John and jdigital are both right - from my understanding, services can generally have either desktop access (you have to use localsystem) or network access (you need to specify an account to run under).

You will need two split your app into two - one to interact with the desktop and the other to talk over the network. The two parts can then talk to each other to relay info to the end user.

like image 57
Andy Stewart Avatar answered Sep 21 '22 02:09

Andy Stewart