Batch File to Schedule WinXP Restart

Posted on Updated on

In a troubleshooting situation with Windows XP hanging during a restart of Windows after a CM07 package deployment, I built a workaround script that creates a scheduled task to perform a forced Windows restart (for 2 minutes after install completion).  The reason for doing 2 minutes is because there are times when the scheduled task can be created in the 59th second of a minute, but there isn’t enough time for the installation to exit.

@echo off 
Set /a MIN=%TIME:~3,2% + 2 
Set /a HOUR=%TIME:~0,2%
:: Remove the echo command to actually schedule the restart 
echo at %HOUR%:%TIME% /interactive C:\Windows\system32\shutdown.exe -r -t 60 -f

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s