views:

41

answers:

2

I have a NT server application running in background on Windows Vista, and I want the server to lanuch Notepad.exe when server received a specific command, BUT it doesn't work, I have tried with shellexec, winexec and createprocess functions, all are failed. Notepad always runs on the server desktop, Vista will show a message to ask me to switch it. is there a way to launch it correctly?

A: 

Have you tried calling CreateProcess with the name of the desktop you want to open it in in the lpDesktop member of the STARTUPINFO structure? See here.

1800 INFORMATION
Yes, I tried it, but it still doesn't work.
Yigang Wu
A: 

This is because of Vista Session 0 isolation. Your service is running in Terminal Services Session 0, your user is logged on to Session 1 or above, and interaction between the two is strictly limited.

The officially supported way of doing what you want is to have a helper application already running on the users desktop, talking to your service via some kind of IPC (e.g. pipes, sockets). Then, when your service wants to interact with the users desktop, it asks the helper application to do it for you.

snowcrash09
Due to the UAC issue, I would like my NT server to avoid it. It means the AP what I want NT server to lanuch need the full Administrator permission. If a helper application is already running on the users desktop, it still need to show the UAC dialog.
Yigang Wu
That's the point of UAC - if your app needs elevated privileges, it should ask the user for permission. Vista is designed to not allow exactly what you're trying to achieve - I'm not saying its impossible, I'm sure the malware community has/will come up with workarounds, but if you're a legitimate developer then you need to rethink your design so that you don't need to defeat UAC or Session 0 isolation.
snowcrash09