Windows’ command line is not shipped with pre-installed sleep functionality, or at least I was unable to find it on older systems such as the target system (Windows 2003 server) I had to use.
The main goal of the task was to restart a (Windows) service on a regular basis. In order to give the service shutdown sequence some time to complete before being started again I wanted to integrate some seconds of sleep time. Unfortunately, the target Windows 2003 server did not have a built-in sleep command. After some thought I recalled the Windows 2003 resource toolkit and hoped to find the missing functionality in there – with success!
sleep.exe offered everything I needed to implement the sleep functionality for the service restart batch file. Simply download and install the toolkit from Microsoft’s homepage and it will add itself to the PATH.
The final solution is shown in the following:
net stop service xyz sleep.exe 10 net start service xyz
An optimization for this script would be for instance to check in advance if the service is started. For more information have a look at these solutions.