I recently wondered how it is possible to shutdown Windows in some prior set time lets say in 30 minutes, 1 hour, 3 hours or 8 hours.
That's handy especially on servers that are being still in preparation install time and you have left some large files copy job (if you're migration files) from Old server environment to a new one
or if you just need to let your home WIndows PC shutdown to save electricity after some time (a very useful example is if you're downloading some 200GB of data which are being estimated to complete in 3 hours but you need to get out and be back home in 2 or 4 days and you don't want to bother connecting remotely to your PC with VNC or teamviewer then just scheduling the PC / server to shutdown in 3 hours with a simple is perfect solution to the task, here is how:
1. Open Command Prompt (E.g. Start menu -> Run and type CMD.EXE)
2. Type in command prompt
shutdown -s -t 10800
If you by mistake has typed it to shutdown earlier and suddenly you find out your PC needs to be running for a short more time in order to cancel the scheduled Shutdown type:
shutdown -a
Shutdown Windows command -s flag has also a possibiltiy to not shutdown but just logoff or if you just need to have the system rebooted a reboot option:
StackExchange.ready(function () {
StackExchange.using("postValidation", function () { StackExchange.postValidation.initOnBlurAndSubmit($('#post-form'), 2, 'answer'); });
StackExchange.question.init({showAnswerHelp:true,totalCommentCount:0,shownCommentCount:0,highlightColor:'#BEB013',backgroundColor:'#FFF',questionId:215531});
styleCode();
StackExchange.realtime.subscribeToQuestion('3', '215531'); StackExchange.using("gps", function () { StackExchange.gps.trackOutboundClicks('#content', '.post-text'); });
});
options effect
-l to log off
-r to reboot
If you need to shutdown the PC after half an hour use instead the command:
shutdown -s -t 1800
Half an hour is 1800 seconds for one hour delayed shutdown use 3600 for 3 hours, that would be 3*3600 10800, for 5 hours 5*3600 = 18000 seconds and so on
An alternative way to do it with a short VBscript, here is an example:
Set objShell = CreateObject("WScript.Shell")
Dim Input
Input = "10:00"'Input = InputBox("Enter the shutdown time here.","", "10:00")
For i = 1 to 2
CurrentTime = Time & VbCrLf
If Left(CurrentTime,5) = Input Then
objShell.Run "shutdown -s -t 00", 0
WScript.Quit 1Else
WScript.Sleep 1000
End If
i=i-1
Next
Enjoy