I have an old (Windows 2003) server running. I then have a Powershell script which I need to execute using a scheduled task (running it on it's own works fine). On all my other (windows 2008) servers, when the Scheduled Task runs, the powershell window displays in the foreground, giving a visual indication that it is running.
But on my Windows 2003 server, it appears to be running, but not in the foreground. My script restarts an application, and when it restarts, I can see in task manager that it is running, but I don't know where.
I am logged in as Administrator. The task is set with
run only if logged in. The Task Scheduler service has
allow service to interact with the desktop ticked.
What else do I need to do to make it run in the foreground, and more importantly, restart my application in the foreground?
I also set up a basic test.cmd file which writes a single line to the screen, and that also doesn't work in task scheduler.
It seems the problem is due to the Task Scheduler running everything in Session 0 (Console), instead of Session 1 (RDP). Is there any way to force it to run the scripts in the correct session (1)?
mstsc.exe /admin(on newer systems) or
mstsc.exe /console(on older systems) will log you in to session 0.