Table of Contents

Microsoft - Windows - Scheduled Tasks

Wayne's World of IT - 2003 Cluster-enabled scheduled tasks

Blogposts/Articles

TechNet Blogs > A Premier Field Engineer in Denmark > Using Delegation in Scheduled Tasks
Microsoft - Ask The Performance Team - Help! My Scheduled Task does not run…
stack overflow - Windows Task Scheduler Doesn't Run VBScript
stack overflow - My script won't run under the task scheduler. Why?

From VBScript

stack overflow - VBScript for creating a scheduled task

Microsoft Docs - Task Scheduler for developers
Microsoft Docs - Task Scheduler Scripting Objects
Microsoft Docs - Time Trigger Example (Scripting)
Microsoft Docs - Logon Trigger Example (Scripting)
Microsoft Docs - LogonTrigger object
Microsoft Docs - LogonTrigger.UserId property
Microsoft Docs - Principal.Id property
Microsoft Docs - Principal.GroupId property

Experts Exchange - Articles - VBScript and Task Scheduler 2.0 : Listing Scheduled Tasks
Experts Exchange - Articles - VBScript and Task Scheduler 2.0 : Creating Scheduled Tasks

Error codes

HexadecimalDecimal (for PowerShell)Meaning
00The task has run successfully.
0x22Access denied. The task should probably be run with “Run with highest privileges.”
0x103259Terminated due to execution timeout
0x41301267009The task is currently running.
0x41303267011The task has not yet run.
0x41306267014The last run of the task was terminated by the user.
0x800700022147942402Cannot find file.
0x8007052E2147943726Logon failure unknown user name error

Microsoft MSDN - Task Scheduler Error and Success Constants
Access denied (0x2) error as an administrator in Windows Task Scheduler
stack overflow - Task Scheduler failed to start. Additional Data: Error Value: 2147943726
Appuals.com - How to Fix Task Scheduler Error Value 2147943726
Get IT Solutions - Error Code 0x8007052e Solutions – unknown user name or bad password.

Notes

0x800704DD error

When running a scheduled task as a local administrator/user you get the following error:

The operation being requested was not performed because the user has not logged on to the network. The specified service does not exist (0x800704DD)

You can run into this if you try to run bitsadmin.exe /AddFile from a (VB)script in a scheduled task (on Windows 7).

Workaround: Create the scheduled task so that it runs under the SYSTEM account or create it as an AT job (which is basically the same as running it as a normal scheduled task under SYSTEM, but with less options).

Scheduled reboot

Schedule a daily reboot of the system at 04:30:

"%SYSTEMROOT%\system32\schtasks.exe" /Create /TN "Reboot daily 0430" /TR "\"%SYSTEMROOT%\system32\shutdown.exe\" /r /t 0 /c \"Daily reboot.\"" /RU SYSTEM /SC DAILY /ST 04:30 /F

Scheduled start of service if not already running

Schedule a daily start of the Connection Broker service at 00:30 if not already running:

"%SYSTEMROOT%\system32\schtasks.exe" /Create /TN "Start Connection Broker daily 0030" /TR "\"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe\" -Command \"if (-Not (Get-Service -Name tssdis ^| Where-Object {$_.Status -eq \\\"Running\\\"})) { Start-Service -Name tssdis }\"" /RU SYSTEM /SC DAILY /ST 00:30 /F

To end up with

\"Running\"

in the scheduled task command it needs to be defined as

\\\"Running\\\"

in the command.
Using ' causes the ' to be expanded to “, and , '', \', or ^' do not work to escape it.

Run every minute / Custom interval

Set the job trigger to “Repeat taks every” and fill in the timespan yourself instead of selecting one of the predefined options.

This might nog always work, see:

Sources: