我正在使用VBScript在我的Win Server 2003上運行應用程序,並且我希望它在設定的時間後關閉用戶。沿着線的東西:如何從vbscript註銷?
Set WshShell = WScript.CreateObject("WScript.Shell")
Set OExe = WshShell.exec("somecommand.exe")
WScript.Sleep 1000000
OExe.Terminate
<Insert LogOff code>
我正在使用VBScript在我的Win Server 2003上運行應用程序,並且我希望它在設定的時間後關閉用戶。沿着線的東西:如何從vbscript註銷?
Set WshShell = WScript.CreateObject("WScript.Shell")
Set OExe = WshShell.exec("somecommand.exe")
WScript.Sleep 1000000
OExe.Terminate
<Insert LogOff code>
喜歡的東西
應該做的伎倆
Wscript.Sleep(100000)
SET wshell = Wscript.CreateObject("Wscript.Shell")
wshell.exec("shutdown.exe -L -F")
剛剛測試這在W7中,似乎好了工作。
實施例使用WMI:
Set oSystems = GetObject("winmgmts:{(Shutdown)}//./root/cimv2").ExecQuery("select * from Win32_OperatingSystem where Primary=true")
For Each oSystem in oSystems
'LOGOFF = 0
'SHUTDOWN = 1
'REBOOT = 2
'FORCE = 4
'POWEROFF = 8
oSystem.Win32Shutdown 0
Next