1. By WSH script
args = WSCript.Arguments.Count
If args<>3 Then
wscript.echo "Usage:"
wscript.echo "cscript //nologo ShutDownmachine.vbs /Machine:<machinename> /Admin:<Administrator> /Pwd:<password>"
Else
set colNamedArguments = WSCript.Arguments.Named
strMachineName = colNamedArguments.Item("Machine")
strUserName = colNamedArguments.Item("Admin")
strPassword = colNamedArguments.Item("Pwd")
Set objLocator = CreateObject("WbemScripting.SWbemLocator")
Set objWBEMService = objLocator.ConnectServer(strMachineName, "root\cimv2", strUserName,strPassword)
If err=0 Then
Set cols=objWBEMService.ExecQuery("Select * from Win32_OperatingSystem")
For each col in cols
col.ShutDown
wscript.echo strMachineName & " is going to shutdown..."
Next
Else
wscript.echo "Failed to Connect machine" & strMachineName
End If
End If
2.By Windows CommandLine if current user have administrative privilege on target machine
c:\>shutdown /s /m <machinename> <cr>
posted on 2007-04-29 16:08
GuangMing Lan 阅读(172)
评论(0) 编辑 收藏 引用