Flying bat in a marquee Flying bat in a marquee Flying bat in a marquee Flying bat in a marquee Flying bat in a marquee Flying bat in a marquee Flying bat in a marquee Flying bat in a marquee Flying bat in a marquee Flying bat in a marquee Flying bat in a marquee Flying bat in a marquee Flying bat in a marquee Flying bat in a marquee Flying bat in a marquee Flying bat in a marquee Flying bat in a marquee Flying bat in a marquee Flying bat in a marquee Flying bat in a marquee Flying bat in a marquee Flying bat in a marquee Flying bat in a marquee Flying bat in a marquee Flying bat in a marquee Flying bat in a marquee

Thursday, July 30, 2009

Windows Vista Shutdown.exe - Maximum allowed timeout value is 600 Seconds

Problem

I used to schedule system shutdown using the command prompt and desktop shortcuts on my old XP SP2 machine: (For example shutdown.exe /s /t 1200). When I try to do this from the command prompt in Vista, I get the shutdown.exe help text displaying after the prompt - almost as if it is ignoring the switches.

Workaround

In Windows XP, there is no upper limit on the timeout value for shutdown.exe tool. Whereas in Windows Vista, the maximum timeout value accepted is 600 seconds (that is, 10 minutes). So, to configure the machine to shutdown in 2 or 3 hours from the current time, you may need to use shutdown.exe in a script or a batch file. You may use my script below:

'Launches "shutdown.exe /s /t xxx" - This script is a workaround...
'... for the 600 seconds time-out limit in Vista.
'Created on March 30, 2007
'Copyright © 2007 Ramesh Srinivasan.
'Winhelponline.com - http://www.winhelponline.com

Set objShell = CreateObject("Wscript.Shell")
strMsg = "Enter the shutdown timeout period (in Seconds)"
iSec = trim(InputBox (strMsg,"Shutdown timeout value",750))
if iSec = "" then wscript.quit
if iSec > 600 then
iSleep = int(iSec) - 600
iSleep = iSleep * 1000
WScript.Sleep iSleep
objShell.Run "shutdown.exe /s /t 600"
else
objShell.Run "shutdown.exe /s /t " & iSec
end If

Copy the above code to Notepad and save the file with .vbs extension (say, turnoff.vbs). To initiate a shutdown, double-click the script and enter the timeout value in Seconds.

The script works this way: If the timeout value entered by the user exceeds 600 seconds, the script sleeps for the exceeded value (i.e., - 600 Seconds) and then invokes Shutdown.exe passing 600 (seconds) as the timeout value.

Note that you can accomplish the same using the sleep.exe tool from the Windows Resource Kit Tools, and using them in a Batch file.

No comments:

Post a Comment