Startup Script + Local System user = no functional program UI

group-policyiis-7scheduled-taskuser-managementwindows-server-2008

I currently have a group policy startup script (CMD file). It runs during startup, as expected, but there is no UI for the program the script invokes.

For example purposes, let's say I have this command as my startup script:

rundll32 shell32.dll,ShellExec_RunDLL "C:\Windows\System32\notepad.exe"
echo foo > C:\foo.txt

^ This invokes "Notepad" to run, and writes output to a textfile (foo.txt). Pretty simple. When group policy runs this script, the text file is produced and Notepad is running. The problem is that Notepad has no UI. The only way I can tell it is running is through Task Manager/Processes. I have verified it working, but I need Notepad to show up in my taskbar, while running.

…According to TechNet/Microsoft here:
Assign computer startup scripts w/ Microsoft

Startup scripts are run as Local System, and they have the full rights that are associated with being able to run as Local System.

My problem is that I really need the Notepad program UI to display and cannot seem to make this happen when it runs under "Local System".

  1. Is there a way to have my startup script run as Administrator? Or is there a way to enable Local System user to have necessary priveleges to fully run Notepad?
  2. Do I need to alter my CMD script to "RUN AS" a different user?
  3. Should I ditch group policy for scheduled tasks? Scheduled tasks are easier to setup. it seems like a toss-up to me?

I would like to point out that I have also tried this with "Scheduled Tasks" under Control Panel/Administrative Tools. I have the same results and same situation, where my script runs successfully but Notepad UI is never displayed. I am open to suggestions using Task Scheduler as well, or different approaches. Thanks!

Best Answer

Getting the UI to display is going to be a real pain.

First, I'd consider wrapping these programs in a service wrapper (like Non-Sucking Service Manager, for example) and letting the Service Control Manager start them on boot. From the sound of your comment these programs really should be coded as Windows services anyway. (I'd love software vendors to stop writing non-Service "service" programs that require my servers to sit logged-on, etc. Crappy timeclock polling programs seem to all be this way, for example.)

This doesn't solve your UI problem. You're not going to get a GUI interface to launch on top of Winlogon in Windows Server 2008 without "helping" the program. You could get programs running via Startup Scripts in Windows Server 2003 to display their UI on top of Winlogon. To do such a thing now you'd need to create a process with a duplicate of the Winlogon token with the desktop set for the Winlogon desktop.

You may get the UI to pop up after logon by allowing the Service-wrapped programs to interact with the desktop. Maybe. You're probably also exposing yourself to "shatter" attacks, too.

If these are in-house programs you should consider altering them so that they work like real Service programs should. The management UI should talk to the back-end service process via an RPC mechanism. Do this over TCP/IP and, as a bonus, you can run the management program on other machines. Your monolithic Service-and-UI-together approach isn't going to give you the best results.