Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

pc shudown script

Status
Not open for further replies.

n3tw0rkadm1n1strat0r

IS-IT--Management
Aug 29, 2006
119
US
I can't figure out why this isn't working...I'm bad with the quotes...It gives me an error saying that the system cannot find the specified file, but I know that it is there.

Code:
Set objShell = CreateObject("Wscript.Shell")

strComputer = InputBox("Enter the PC name to shutdown:")
strMessage = InputBox("Enter the message to display:")
strTime = InputBox("Enter the time in seconds to shutdown:")

objShell.Run("""%comspec% /K C: | cd WINDOWS\system32 | shutdown.exe -r -m \\""strComputer"" -t ""strTime"" -c ""strMessage"" """), 0, True

Set objShell = Nothing
 
Is by chance your script named shutdown.vbs ?
Try this:
objShell.Run "%comspec% /K shutdown[!].exe[/!] -r -f -t " & strTime & " -c " & Chr(34) & strMessage & Chr(34) & " -m \\" & strComputer, 0, True

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
You can shutdown a PC without using the Shutdown.exe command:

Code:
Const SHUTDOWN = 1

strComputer = "."
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate,(Shutdown)}\\" & strComputer & "\root\cimv2")
Set colOperatingSystems = objWMIService.ExecQuery ("Select * from Win32_OperatingSystem")
For Each objOperatingSystem in colOperatingSystems
	objOperatingSystem.Win32Shutdown(SHUTDOWN)
Next
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top