3

i am planning to run a launch/monitor a UI application using a windows service(written in C#).with "Allow service to interact with desktop " checked. this works fine with windows xp, but with windows 7 a pop is shown as below

enter image description here

and when i click on view the message , then the whole screen blanks out,with only UI showing up ,as shown below.

enter image description here

is there any way to make it work without the message being shown and screen going blank.

comments/suggestions appreciated.

Regards DEE

DEE
  • 373
  • 5
  • 17

2 Answers2

7

In Vista and later, services cannot interact with the desktop. Services run under what is known as session 0 isolation. What you are attempting is simply impossible.

You will have to re-write your application so that the UI part resides in a standard Windows application that runs on the logged in user's desktop. This UI part can communicate with the service by whatever IPC mechanism you prefer.

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
  • WCF with named pipes are a good choice for such scenario. Just be careful on the security implications. The API you will publish won't require UAC elevated privileges... but the service will have (actually it depends on the identity of the process). If misused, the api can be a gateway for malicious code – Steve B Sep 08 '11 at 11:46
  • @Steve Of course best practice is to run services as restricted users and definitely to avoid the `SYSTEM` account. – David Heffernan Sep 08 '11 at 11:47
3

"Allow service to interact with desktop " is a legacy option that is now highly discouraged, and although it exists, is not expected to work in Windows Vista and upwards.

You need to read a bit on why this is the case in this other SO answer:
Allow service to interact with desktop in Windows

Then look for the alternatives discussed in the answer here:
Alternative to "Allow service to interact with desktop"?

Another discussion outside SO:
http://social.msdn.microsoft.com/forums/en-US/windowssdk/thread/f8f91e8f-5954-43a7-8bc4-80ed2ff1e3b1/

Community
  • 1
  • 1
Meligy
  • 35,654
  • 11
  • 85
  • 109