Windows Services – Why No GUI?

netwindows

I was using this feature in earlier Windows release like XP and NT. I was able to run a GUI from a Windows service. But it is not possible in the later versions.

What is the reason behind the removal of this feature? Why can't Windows services have a GUI?

Best Answer

Mainly security reasons.

As I understand it, when a windows service creates GUI controls such as a MessageBox, they were normally only seen in the session that the services runs in ie Session 0 which also used to be the first user logged on locally or by someone logging on using mstsc /admin. Hence this user would see these controls and could interact with the service.

But for security reasons, Session 0 is now reserved and the first user to log on will be given a new session and hence not see the GUI Controls.

Since this breaks quite a lot of services, for compatibility, there is a process (see this MSDN blog) that attempts to detect if any messages are being displayed and popups with a warning 'A program running on this computer is trying to display a message' and allows you to view or ignore the message.

Microsoft have a WhitePaper on this subject which you can download from here

I would also suspect that another minor reason is because the feature was misused/misunderstood and led to bad designs. For example, I used to have an old server with a third-party service that displayed some notifications/errors using a message box rather than writing to the event log. But I never logged on locally and rarely logged in in admin mode and hence I would not see the messages.