给你个脚本试试
on error resume next
if (lcase(right(wscript.fullname,11))="wscript.exe") then
set objShell=wscript.createObject("wscript.shell")
objShell.Run("cmd.exe /k cscript "&chr(34)&wscript.scriptfullname&chr(34))
wscript.quit
end if
if wscript.arguments.count<>3 then
usage()
wscript.echo "Error: Not enough parameters."
wscript.quit
end if
ipaddress=wscript.arguments(0)
username=wscript.arguments(1)
password=wscript.arguments(2)
if ipaddress="127.0.0.1" or ipaddress="localhost" then
strComputer="."
wscript.quit
end if
wscript.echo "Conneting "&ipaddress&"...."
set objlocator=createobject("wbemscripting.swbemlocator")
set objswbemservices=objlocator.connectserver(ipaddress,"root/default",username,password)
showerror(err.number)
set objlocator=createobject("wbemscripting.swbemlocator")
strComputer=ipadress
set objswbemservices=objlocator.connectserver(ipaddress,"root\cimv2",username,password)
Set colOperatingSystems = objswbemservices.ExecQuery_
("Select * from Win32_OperatingSystem")
For Each objOperatingSystem in colOperatingSystems
ObjOperatingSystem.Reboot()
Next
function showerror(errornumber)
if errornumber<>0 then
wscript.echo "Error! "
wscript.quit
else
wscript.echo "OK!"
wscript.echo " "
end if
end function
function usage()
wscript.echo "Reboot the RemoteHost "
wscript.echo "Welcome to www.isgrey.com"
wscript.echo " "
wscript.echo "Usage:"
wscript.echo "cscript "&wscript.scriptfullname&" targetIP username password"
wscript.echo " "
end function