views:

273

answers:

4

I am writing a .NET Windows service whose role is to launch a GUI application(whose source is unavailable). The operation is a fire and forget, no communication besides initial command-line parameters.

The service ought to run as a given Windows account.

Problem: The app that the service launches is not displayed on the desktop. It needs to be, as it is an interactive app. What is the solution?

Note: this is the specification and the design of the system. The typical concerns raised with service/app communication and security do not apply in this specific case.

edit: The GUI elements display correctly when logged in as the Local System account, however, due to the GUI app needing to access networked drives(It can't understand UNC mapping), it needs to be run as a specified user account, and that does not have a "display interactive elements" setting.

edit2: The OS is Windows 2003 Server, and there are no plans to upgrade it.

A: 

This is a stab in the dark but hopefully will lead you down some sort of path to the solution.

Even though security isn't a concern, it may be the problem. The service is launching the app under a different set of credentials than the currently logged in user. It'd be like Remote Desktop to a users machine and launch an app that they would see.

As a test, perhaps change the credentials of the service to the currently logged in user just to see what happens.

Since a service runs even though a user isn't logged in, what happens if it launches the app? Your business rules or functionality might keep that from happening, but perhaps windows is doing something to keep it from working.

Joshua Belden
edited for clarity. Security definitely is the "problem" here.
Paul Nathan
+2  A: 

This is, unfortunately, more problematic since Vista... Some details as to why are posted on this blog post.

That post has some references to a couple of potential workarounds. Here is a thread on MSDN that details the entire process, and some of the potential hiccups you may face.

However, I'd highly recommend trying to see if you can switch to having a user-mode application run as a startup app (when the user logs in), and any communication to your service be handled by that application. It's much more reliable, especially under vista, terminal services, and other situations.

Reed Copsey
Server is Win2K3, and it can stay that way. The specified goal is that the preferred method is having the app run as a service.
Paul Nathan
A: 

You can use free Autologon utility http://technet.microsoft.com/en-us/sysinternals/bb963905.aspx from Sysinternals/Microsoft and put you application into Startup for autologon user profile. After that you can configure screen sever to start in several minutes and check "On resume, display logon screen" checkbox.

Dmitri Kouminov
A: 

Do you expect your application/service to work when the terminal server role is enabled? If so, you really need to do the "application which polls the service" model and not the "service which launches the application" model.

The reason for this is that you may have multiple users connected to the machine at any time and there's no way of knowing which is at the "console" - in fact there might be nobody at the console at all.

Larry Osterman