(view source code of reboot.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 reboot commandFor Each OpSys In OpSysSet
OpSys.Reboot()
NextSub Syntax Dim strMsgstrMsg = "Reboot.vbs, Version 2.10" & vbCrLf _
& "Reboot 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 rebooted" & vbCrLf _
& " (without leading backslashes)." _
& vbCrLf & vbCrLf _
& " 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.0097 seconds