1

VBScriptを使用してWinServer2003でアプリケーションを実行していますが、設定した時間が経過するとユーザーをログオフさせたいと考えています。次のようなもの:

Set WshShell = WScript.CreateObject("WScript.Shell")
Set OExe = WshShell.exec("somecommand.exe")
WScript.Sleep 1000000
OExe.Terminate
<Insert LogOff code>
4

3 に答える 3

2

何かのようなもの

WshShell.Run "C:\windows\system32\shutdown.exe /l", 0, false

トリックを行う必要があります

于 2010-10-15T00:31:09.527 に答える
2
Wscript.Sleep(100000)  
SET wshell = Wscript.CreateObject("Wscript.Shell")  
wshell.exec("shutdown.exe -L -F")  

これをw7ボックスでテストしたところ、問題なく動作しているようです。

于 2010-10-15T00:38:19.650 に答える
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
于 2010-10-20T19:30:25.967 に答える