======Microsoft - Windows - Scheduled Tasks======
[[http://waynes-world-it.blogspot.com/2008/04/2003-cluster-enabled-scheduled-tasks.html|Wayne's World of IT - 2003 Cluster-enabled scheduled tasks]] \\
=====Blogposts/Articles=====
[[http://blogs.technet.com/b/craigf/archive/2011/03/15/using-delegation-in-scheduled-tasks.aspx|TechNet Blogs > A Premier Field Engineer in Denmark > Using Delegation in Scheduled Tasks]] \\
[[https://techcommunity.microsoft.com/t5/ask-the-performance-team/help-my-scheduled-task-does-not-run-8230/ba-p/375528|Microsoft - Ask The Performance Team - Help! My Scheduled Task does not run…]] \\
[[https://stackoverflow.com/questions/29663480/windows-task-scheduler-doesnt-run-vbscript|stack overflow - Windows Task Scheduler Doesn't Run VBScript]] \\
[[https://stackoverflow.com/questions/665014/my-script-wont-run-under-the-task-scheduler-why|stack overflow - My script won't run under the task scheduler. Why?]] \\
=====From VBScript=====
[[https://stackoverflow.com/questions/31549393/vbscript-for-creating-a-scheduled-task|stack overflow - VBScript for creating a scheduled task]]
[[https://docs.microsoft.com/en-us/windows/win32/taskschd/task-scheduler-start-page|Microsoft Docs - Task Scheduler for developers]] \\
[[https://docs.microsoft.com/en-us/windows/win32/taskschd/task-scheduler-objects|Microsoft Docs - Task Scheduler Scripting Objects]] \\
[[https://docs.microsoft.com/en-us/windows/win32/taskschd/time-trigger-example--scripting-?redirectedfrom=MSDN|Microsoft Docs - Time Trigger Example (Scripting)]] \\
[[https://docs.microsoft.com/en-us/windows/win32/taskschd/logon-trigger-example--scripting-|Microsoft Docs - Logon Trigger Example (Scripting)]] \\
[[https://docs.microsoft.com/en-us/windows/win32/taskschd/logontrigger|Microsoft Docs - LogonTrigger object]] \\
[[https://docs.microsoft.com/en-us/windows/win32/taskschd/logontrigger-userid|Microsoft Docs - LogonTrigger.UserId property]] \\
[[https://docs.microsoft.com/en-us/windows/win32/taskschd/principal-id|Microsoft Docs - Principal.Id property]] \\
[[https://docs.microsoft.com/en-us/windows/win32/taskschd/principal-groupid|Microsoft Docs - Principal.GroupId property]] \\
[[https://www.experts-exchange.com/articles/11326/VBScript-and-Task-Scheduler-2-0-Listing-Scheduled-Tasks.html|Experts Exchange - Articles - VBScript and Task Scheduler 2.0 : Listing Scheduled Tasks]] \\
[[https://www.experts-exchange.com/articles/11591/VBScript-and-Task-Scheduler-2-0-Creating-Scheduled-Tasks.html|Experts Exchange - Articles - VBScript and Task Scheduler 2.0 : Creating Scheduled Tasks]] \\
=====Error codes=====
^Hexadecimal^Decimal (for PowerShell)^Meaning^
|0|0|The task has run successfully.|
|0x2|2|Access denied. // The task should probably be run with "Run with highest privileges." //|
|0x103|259|Terminated due to execution timeout|
|0x41301|267009|The task is currently running.|
|0x41303|267011|The task has not yet run.|
|0x41306|267014|The last run of the task was terminated by the user.|
|0x80070002|2147942402|Cannot find file.|
|0x8007052E|2147943726|Logon failure unknown user name error|
[[http://msdn.microsoft.com/en-us/library/aa383604.aspx|Microsoft MSDN - Task Scheduler Error and Success Constants]] \\
[[http://www.kineticcomputer.com/tips/1401-last-run-result-(0x2)-in-task-scheduler-as-administrator.htm|Access denied (0x2) error as an administrator in Windows Task Scheduler]] \\
[[https://stackoverflow.com/questions/44348330/task-scheduler-failed-to-start-additional-data-error-value-2147943726|stack overflow - Task Scheduler failed to start. Additional Data: Error Value: 2147943726]] \\
[[https://appuals.com/how-to-fix-task-scheduler-error-value-2147943726/|Appuals.com - How to Fix Task Scheduler Error Value 2147943726]] \\
[[https://www.get-itsolutions.com/error-code-0x8007052e-solutions-unknown-user-name-or-bad-password/|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:
* [[https://somoit.net/windows/scheduled-task-every-minute#comment-13684|Comment from Mateusz]]
* [[https://stackoverflow.com/questions/4249542/run-a-task-every-x-minutes-with-windows-task-scheduler#comment9792360_4250516|Comment from JoshuaDavid]].
Sources:
* [[https://somoit.net/windows/scheduled-task-every-minute|SomoIT - Windows – Configure scheduled task every minute]]
* [[https://stackoverflow.com/questions/4249542/run-a-task-every-x-minutes-with-windows-task-scheduler|stack overflow - Run a task every x-minutes with Windows Task Scheduler [closed]]]