想要个.vbs的自动关机程序代码

来源:百度知道 编辑:UC知道 时间:2024/06/07 13:00:16
那位大哥大姐能帮一下,谢谢啊!

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate,(Shutdown)}!\\" & strComputer & "\root\cimv2")
Set colOperatingSystems = objWMIService.ExecQuery _
("Select * from Win32_OperatingSystem")
For Each objOperatingSystem in colOperatingSystems
ObjOperatingSystem.Win32Shutdown(1)
Next

第二个:指定关机时间

set wso=wscript.createobject("Wscript.Shell")

b=Chr(32)

t=inputbox("输入预定关机时间,以分为单位;如值为空,则为取消自动关机")

if t="" then

wso.run("shutdown "&b&" -a")

else

t=t*60

end if

wso.run("shutdown "&b&" -s "&b&" -t "&b&" "&t&"")

wscript.quit