(view source code of shutdown.vbs as plain text)
Option ExplicitDim strComputer, strQuery' Check command line argumentsIf WScript.Arguments.Named.Count > 0 Then Syntax
Select Case WScript.Arguments.Unnamed.Count
Case 0
' Default is local computer if none specifiedstrComputer = "."
Case 1
If InStr( WScript.Arguments.Unnamed(0), "?" ) > 0 Then
' A "?" in the argument means display helpSyntax
ElsestrComputer = WScript.Arguments.Unnamed(0)
End If
Case Else
' No more than 1 argument allowedSyntax
End Select
' Connect to computerstrQuery = "SELECT * FROM Win32_OperatingSystem WHERE Primary=True"
Set OpSysSet = GetObject( "winmgmts:{(Shutdown)}//" & strComputer & "/root/cimv2" ).ExecQuery( strQuery )
' Actual shutdown commandFor Each OpSys In OpSysSet
OpSys.Shutdown()
NextSub Syntax Dim strMsgstrMsg = "Shutdown.vbs, Version 1.10" & vbCrLf _
& "Shutdown any WMI enabled computer on the network." _
& vbCrLf & vbCrLf _
& "Usage: " & UCase( WScript.ScriptName ) _
& " [ computer_name ]" & vbCrLf & vbCrLf _
& "Where: ""computer_name"" is the name of the " _
& "computer to be shut down (no" & vbCrLf _
& " leading backslashes); " _
& "default is the local computer." & vbCrLf & vbCrLf _
& "Based on a post by Alex Angelopoulos on www.developersdex.com." _
& vbCrLf & vbCrLf _
& "Written by Rob van der Woude" & vbCrLf _
& "http://www.robvanderwoude.com"
Wscript.Echo( strMsg )
Wscript.Quit 1
End Sub
page last modified: 2025-10-11; loaded in 0.0073 seconds