show a windows form from a window service

Cant be done*. In later Operating Systems that won’t work as Windows Services are disallowed from interacting with the Desktop – instead UI presented by Windows Services is shown in Session 0, a special logon session which is not normally visible to the end user.

What you should instead do is write a separate Windows Forms application which is always running, but not always visible (possibly have that application run at startup and have an icon in the notification area) and communicates with the Windows Service using some form of IPC

When the Windows Service wishes to display some UI to the user it sends a message to the application, which in turns shows the desired UI to the end user.

*or at least it definitely shouldn’t be done

Leave a Comment