Link to home
Start Free TrialLog in
Avatar of lovemask
lovemask

asked on

shutdown script

i need shutdown vbscript with msgbox " your computer will shutdown in x min Press Cancel to abort " 
if no one press cancel the shutdown command is going to continue. i have tried to write a script i need your help !!

TimeOut = 1 '(in minutes) how to use ?
or is there another way ??

dim objShell
Set WshShell = CreateObject("WScript.Shell") 
userschoice = Msgbox("The Computer is shuting down now", VBOKCancel + vbExclamation,"Caution")
 
If vbOK Then
        objShell.Run "shutdown.exe -s -t 30"
else
        Msgbox "Shutdown abortet"
End if

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of ou_dober
ou_dober
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
BTW ~ Adjust line 25 where 30 is the seconds it will wait before acting on its own without user intervention.
Avatar of lovemask
lovemask

ASKER

thank you it seems working ... im testing it now
Here's the one for rebooting
Set for 10 sec on no user intervention.
' Reboot.vbs
' Example VBScript to Reboot computers w/ user input
' Author Lance Dobbs
' Version 1.1 - July 2009
' --------------------------------------
Dim objShell, strComputer, strInput
Dim strReboot
 
' This parameter is for when the user clicks on the yes box.(adjust -t as needed - default 0 min.)
strReboot1 = "Shutdown -r -t 0 -f -m \\" & strComputer
' This parameter is for when the user clicks on the no box. (adjust -t as needed - default 5 min.)
strReboot2 = "Shutdown -r -t 300 -f -m \\" & strComputer
' This parameter is for when the user does nothing. (adjust -t as needed - default 0 min.)
' If this is not needed, REM out the line with "	objShell.Run strReboot3"
strReboot3 = "Shutdown -r -t 0 -f -m \\" & strComputer
 
Const wshYes = 6
Const wshNo = 7
Const wshYesNoDialog = 4
Const wshQuestionMark = 32
 
Set objShell = CreateObject("Wscript.Shell")
 
intReturn = objShell.Popup("Your computer needs to be rebooted. Do you wish to proceed right now?", _
    10, "***** Reboot REQUIRED *****", wshYesNoDialog + wshQuestionMark)
 
If intReturn = wshYes Then
   	Wscript.Echo "You clicked the Yes to Reboot your computer now."
	objShell.Run strReboot1
ElseIf intReturn = wshNo Then
    	Wscript.Echo "You clicked the No button. Your computer will Reboot in 5 minutes. Please close all applications."
	objShell.Run strReboot2
Else
    	Wscript.Echo "The popup timed out. Computer will Reboot now."
	objShell.Run strReboot3
End If

Open in new window

thank you i did some modification that meet my requirements