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

23
2014-04
  • colemik

    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)?

  • Answers
    Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

    Related Question

    task scheduler - Windows XP: schtasks without requiring password
  • Android Eve

    I am trying to create a script that uses schtasks to schedule a task, without entering a password. The task is intended to simply run under the currently logged on user, who actually creates the task (via the script).

    Thus, the user's credentials are there, otherwise the task wouldn't have been created.

    Here is an example of such statement I used in my tests:

    schtasks /create /tn startCalc /tr "C:\WINDOWS\system32\calc.exe" /sc DAILY /st 22:53:00
    

    Unfortunately however, "Task Scheduler" fails to run the scheduled task with the following logged error:

    The attempt to retrieve account information for the specified task failed; therefore, the task did not run. Either an error occurred, or no account information existed for the task. The specific error is: 0x8004130f: No account information could be found in the Task Scheduler security database for the task indicated.

    Now, the task is not a system-level command or anything like that. It is a benign user-level application (e.g. Notepad or Calc).

    I could, of course, embed in the script some code that would ask the user to type his password, but I prefer to avoid doing so.

    To further clarify the problem, my script should be able to run on "irresponsible home user" computers, who have a single account with admin privileges but without a password! (sounds crazy but there are many users out there working this way whom I can't really educate). So, even if included a password entry prompt in the script, this wouldn't work for those users who have an "empty password".

    Is there a way to tell schtasks to NOT require a password, similar to what to what the "Scheduled Task Wizard" does via the "run only if logged on" checkbox in "advanced properties"?


  • Related Answers
  • CLJ

    try adding "/ru system" to the end of the command

  • Android Eve

    I ended up embedding in the script a requirement for the user to type his password. AFAIK, either schtasks or its documentation is buggy.