So today was another day with another cryptic error from the Windows Server 2008 R2 Task Scheduler. Interestingly (or as usual may be 🙂 ), the MSDN article on Task Scheduler Error and Success Constants is missing the error code. A further look into the task’s history revealed a message saying “Task Scheduler successfully completed task “\Restart Service” , instance “{ca1e5236-51d1-483f-9c39-40832f015120}” ,action “C:\Windows\System32\sc.exe” with return code 1639.” with a return code of 1639.

1639 in the MSDN article “System Error Codes (1300-1699)” referred to “ERROR_INVALID_COMMAND_LINE” which indeed it was because I was trying to use “;” as the command separator with PowerShell in mind. Replacing “;” with “&&” fixed the problem.

Note – This was a fast publish article so that the information is available to everyone without delay. Fast publish articles of mine may not be very well formatted initially.