KTS_HOWTO: Start a program on the currently logged in users desktop.
Few people had asked how to run a program on the user desktop from within KTS session.
I used to answer that it's not possible, actually I wasn't totally right you can start a program on the user desktop, kinda.
OK, first the problem in details (to whoever is interested).
KTS sessions are started on separate "hidden" windows station and desktop. This means that every process started from within KTS session by default will run on these "hidden" winsta and desktop with no access to the "input" desktop (or the user desktop).
The obvious solution is to tell a program to not use the KTS desktop but instead attach itself to the "user" desktop. But you have to consider one more thing, the windows access control model. Windows stations and desktops as almost any other object in the Windows world are securable object, this means that the system (based on the objects access control model) controls the access to these objects.
In a perfect world the user running the KTS session would have all the permissions necessery to change the the "user" winsta and desktop discretionary access control list and grant itself access to these winsta and desktop.
Luckily we are not living in perfect world, we are living in a dangerous place where users should run with the least possible permissions.
The result is that this approach sucks, and you can't start a program on the "user" desktop directly.
What you can do instead is to ask(or force) the logged in user to grant you access to "his" desktop.
How to start a program on the user desktop
1) Get the ondesk.exe program
2) Ask the logged in user to run "ondesk.exe allow", if you are evel enough you can set this up to start automatically upon login.
The "ondesk.exe allow" command will strip any securities applied over the "user" winsta nad desktop and replace them with null DACL.
A null DACL grants full access to any user that requests it; normal security checking is not performed with respect to the object.
Null DACL is a HUGE SECURITY RISK - Use At Your Own Risk!
3) Once the security is stripped from the "user" winsta and desktop, you can run "ondesk.exe <program name here>" from within KTS session and your program will run on the "user" desktop.
Although the program runs on the user desktop it runs under the account of the logged KTS user.
In short this means that if the computer admin logs through KTS and runs "ondesk.exe explorer.exe" the user will have full access to the computer through the "explorer.exe" as it will run with admin rights.
Finally, one more time - Use At Your Own Risk!
ondesk.exe source, use for whatever you like at your own risk:
Tuesday, September 04, 2007
© 2002 - 2008 Kroum Grigorov