User Tools

Site Tools


microsoft:windows:scheduledtasks

Microsoft - Windows - Scheduled Tasks

Blogposts/Articles

From VBScript

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:

microsoft/windows/scheduledtasks.txt · Last modified: 2022/12/05 08:25 by bas

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki