Windows 7 Task Scheduler Hidden setting doesn't work

Check the "Run whether user is logged on or not" check box and executable will run in the background.


Why is Windows 7 scheduled task running hidden? should explain why this happens.

Also, this TechNet description of General Task Properties states:

The general properties of a task are displayed on the General tab of the Task Properties or Create Task dialog box. The general properties of a task include the task name, author, description, security options, the operating system that the task is configured for, and a property that controls whether the task is hidden.

When you create a task in a task folder, you must name the task. No two tasks can have the same name if they are in the same task folder. The task description is optional.

Task security options specify the security context that the task runs under. For more information, see Task Security Context.

By default, hidden tasks are not shown in the Task Scheduler user interface. You can view hidden tasks when Show Hidden Tasks is selected in the View menu. You make a task hidden when you click the Hidden check box on the General tab of the Task Properties or Create Task dialog box.

Doesn't this imply that the checkbox only hides the task itself from the scheduler's UI, and not the actual program that's scheduled?


Okay, after some more research I found this answer on StackOverflow:

To setup a Scheduled Task to run in background, change the User running the task to SYSTEM, and nothing will appear on your screen.

A comment points out that this grants full rights to the task, which could be annoying, but is acceptable in this case.

But still, what does Hidden do, if it doesn't do this? And why would the user account running the program have anything to do with whether it's visible?


THE ULTIMATE SOLUTION

  • Changing the User running the task to SYSTEM - will execute your command not under your user
  • Checking the "Run whether user is logged on or not" - requires to save password with the task, and will hiddenly break next time password changes (what usually enforced by domain policies in enterprise environments)

If those are deal breakers for you, the ultimate solution is to create JS script file like the one below, that will run your command in hidden window, wait for your command to terminate and return its error code:

WScript.CreateObject("WScript.Shell")
.Run('powershell -File C:\\Path\\To\\MyScript.ps1', 0,true);

Save this as js file (myjob.js) and add this to your task scheduler: enter image description here Enjoy


"Run whether user is logged on or not" will allow the hidden option to work. Note that you need provide your credentials after you choose this.