2010-10-15 88 views
1

我正在使用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> 

回答

2

喜欢的东西

应该做的伎俩

2
Wscript.Sleep(100000) 
SET wshell = Wscript.CreateObject("Wscript.Shell") 
wshell.exec("shutdown.exe -L -F") 

刚刚测试这在W7中,似乎好了工作。

0

实施例使用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