2

I am working on a C++ software that runs as a Windows service. Basically this software provides different server services based on internal and external data.

Now there is a customer request that sometimes another program with a graphical user interface shall be started by the service, e.g. when certain data within our software changes.

Once started, these programs are completely independent of our software - neither do we send data to these programs nor do we receive data from these programs. The only thing we have to monitor is whether these programs are closed by the user.

The problem now is to let a GUI program be started by a service. Since the service runs in the protected session 0, according to Microsoft it cannot have a GUI or start a GUI program by default.

We therefore registered our service as an interactive service and enabled interaction in the registry.

Furthermore, we have created our own local user; so we know name and password.

Without being Windows super experts, we tried to research how to solve this task.

If there is any solution, it seems, the LogonUser() and CreateProcessAsUser() functions will do the job.

By now, our service can start processes as a user, but despite all efforts, including setting windows station and desktop, process are always started in session 0 and without GUI.

Hence the question: Is it possible AT ALL to have a GUI application started by a service?

And if so, is there any detailed documentation or even workable sample code anywhere?

The individual Microsoft pages are a good reference if you know exactly what you want to do (and just can't remember the order of the parameters), but don't necessarily provide the level of detail you need to know in a challenge like this.

  • As far as I know a service cannot have a GUI. But you can have a GUI app that automatically starts when the user logins, and communicate with the service in a IPC method (e.g. sockets). This way the service can send messages to the GUI app to do whatever you need. – wohlstad Aug 01 '22 at 08:10
  • 2
    Start a hidden process on login which your service can communicate with a pipe/socket etc. the hidden process can then launch the GUI – Alan Birtles Aug 01 '22 at 08:10

0 Answers0