' Shutdown.vbs
' Example VBScript to shutdown computers w/ user input
' Author ou_dober
' Version 1.1 - July 2009
' --------------------------------------
Dim objShell, strComputer, strInput
Dim strShutdown
' This parameter is for when the user clicks on the yes box.(adjust -t as needed - default 0 min.)
strShutdown1 = "shutdown -s -t 0 -f -m \\" & strComputer
' This parameter is for when the user clicks on the no box. (adjust -t as needed - default 5 min.)
strShutdown2 = "shutdown -s -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 strShutdown3"
strShutdown3 = "shutdown -s -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 shutdown. Do you wish to proceed right now?", _
30, "***** SHUTDOWN REQUIRED *****", wshYesNoDialog wshQuestionMark)
If intReturn = wshYes Then
Wscript.Echo "You clicked the Yes to shutdown your computer now."
objShell.Run strShutdown1
ElseIf intReturn = wshNo Then
Wscript.Echo "You clicked the No button. Your computer will shutdown in 5 minutes. Please close all applications."
objShell.Run strShutdown2
Else
Wscript.Echo "The popup timed out. Computer will shutdown now."
objShell.Run strShutdown3
End If
' Reboot.vbs
' Example VBScript to Reboot computers w/ user input
' Author ou_dober
' 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
Have a question about something in this article? You can receive help directly from the article author. Sign up for a free trial to get started.
Comments (2)
Commented:
Author
Commented: