By David Wiseman (Administrator)Created 05 Aug 2006
My Rating:
Vote
Rating:
Not Rated
Views:12520
Downloads:251

Shutdown a Computer

Language:  VBScript

Compatibility

Windows XP Yes Windows 2003 Yes
Windows 2000 Unknown Windows NT Unknown
Vista Unknown Windows 2008 Unknown
Description

Shutdown local/remote computer.


Notes
Change strComputer variable to shutdown a remote computer. 
Code

Line Numbers: On  Off      Plain Text
strComputer = "." ' Local Computer
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate,(Shutdown)}\\" & _
        		strComputer & "\root\cimv2")

Set colOs = objWMIService.ExecQuery("Select * from Win32_OperatingSystem")
 
For Each objOs in colOs
	objOs.Win32Shutdown(1)
Next

 


Got a useful script? Click here to upload!


 

  Post Comment
Order By:  
User Comments
      
sg7medic
Posted On: 11/12/2007 5:15:02 PM

I tried the script and it works (many scripts found on the net don't)
thank you.
I am using this script with the task scheduler to shut down the office computers at 6pm. In case someone might be staying late, I want to warn them.

request:
display a message box stating computer will shutdown in 3 minutes and add a 3 minute delay to the shutdown script.

thanx again
michael (user: sg7medic)