Why Task Scheduler fails to open a GUI application window when /sc onstart parameter specified?

2

1

This works:

schtasks /create /tn calc /tr c:\Windows\system32\calc.exe /sc minute

After running this and a computer restart:

schtasks /create /tn calc /tr c:\Windows\system32\calc.exe /sc onstart

the calc.exe process is present in Task Manager, but the calc window is missing.

When I run the onstart task manually, the calc window shows up:

schtasks /run /tn calc

What I've tested so far:

  • calc.exe, osk.exe, cmd.exe
  • ping -n 30 127.0.0.1 //a 'sort of' sleep function
  • a .bat file which created a new file and writes a line of text inside the file - worked as expected, but there was no GUI window visible
  • c:\Windows\SchedLgU.txt log file - no errors

All tasks were run by the user that was in the Administrators group.

Why Task scheduler fails to open a GUI application window when /sc onstart parameter specified (or what am I doing wrong)?

colemik

Posted 2012-03-06T11:45:39.877

Reputation: 1 414

did you try a delay in the scheduler? or a full 30 second delay in a batch. I am wondering if it is possible that all the desktop noise is going on, and other startup things, and it is just the usual thrashing mess. EX: with XP in the other computer the User tries to run the corner tv program before the mess of other things is done and settled, it can lockup. The user waits till everything is settled first. – Psycogeek – 2012-03-06T16:18:21.480

how many times have you seen :-) a visual indication of the stuff that runs out of the task scheduler. Imo that is what makes the thing evil. In the win 7 one there are even switches for insuring hidden. So be sure to get in there and see what your command line entries are ending up via the GUI and all the switches in there. – Psycogeek – 2012-03-06T16:35:11.113

@Psychogeek: thanks for the response. Actually, I was able to see the cmd window and the calc window if I logged in really fast, but this occured only once contrary to multiple tests I've made. I'm not sure, but the window showed up probably because I logged in so fast that the Scheduler service was running after I logged in on my user account this one single time (as Task Scheduler is a service and services are launched before the login screen). I'd be really glad for some confirmation / description why it works the way it works (as the calc.exe proc was launched by the user I log in as). – colemik – 2012-03-06T18:23:33.007

Ahhh. I autolog locally. what would be the ramifications for you to have it occur after log-in? – Psycogeek – 2012-03-06T18:28:59.337

@Psycogeek: I'm not sure what you mean by the 'ramifications' (I'm not a native speaker;) ). Services are run before Windows login prompt. I've asked a similar question here and in deed Task Scheduler is one of the last services on the list. Now if I log in very quickly, the Task Scheduler service is probably started after I log in. I, like you, also log in locally, just to be clear. If by ramifications you mean, could I use some other solution, like /sc onlogon parameter

– colemik – 2012-03-06T20:13:14.537

1then I have to explain that I've asked the question purely because I'm testing the schtasks command and I just want to understand how it works the way it works. – colemik – 2012-03-06T20:13:43.443

1I came across the same problem. Could you solve this somehow? Since I have found absolutely no solution approach, because MS thinks everything is running as it should. Or just the event / log If the major log meaningful would. – None – 2012-10-03T18:57:46.540

No answers