Posts

Showing posts with the label schedule task

How to: Create a Windows Service Kickstarter using Powershell

Since some legacy Windows services are getting more and more unstable and fall apart without any means of recovery, a kickstarter is needed to ensure those important(?) services don't just disappear quietly without any struggle. The idea is to use a combination of Powershell script and Task Scheduler to trigger the job every now and then. 0. Precondition The Windows Server 2003 R2 does not come with Powershell installed. To allow Powershell scripts to run on the machine, follow the link to download and install it, and bear in mind, system reboot will NOT be required. 1. Powershell Script Powershell is really easy to pick up. It only requires basic knowledge of Command Prompt, and the rest is just C#. function ServiceKickstarter($serverName, $serviceName) {       $service = Get-Service -ComputerName $serverName -Name $serviceName     if ($service.Status -eq "Stopped")     {         ...

Tips and Hints: Windows Server 2008 Scheduled Tasks Result Codes

0 or 0x0: The operation completed successfully. 1 or 0x1: Incorrect function called or unknown function called. 12 or 0x2: File not found. 110 or 0xa: The environment is incorrect. 0x41300: Task is ready to run at its next scheduled time. 0x41301: Task is currently running. 0x41302: Task is disabled. 0x41303: Task has not yet run. 0x41304: There are no more runs scheduled for this task. 0x41306: Task is terminated. 0x8004130F: Credentials became corrupted (*) 0x8004131F: An instance of this task is already running. 0x800704DD: The service is not available (is 'Run only when an user is logged on' checked?) 0xC000013A: The application terminated as a result of a CTRL+C. 0xC06D007E: Unknown software exception. Ref: http://msdn.microsoft.com/en-us/library/aa383604