代码之家  ›  专栏  ›  技术社区  ›  tzenes

如何从vbscript注销?

  •  1
  • tzenes  · 技术社区  · 16 年前

    我正在使用vbscript在我的Win Server 2003上运行一个应用程序,我希望它在一段时间后注销用户。沿着这条线的东西:

    Set WshShell = WScript.CreateObject("WScript.Shell")
    Set OExe = WshShell.exec("somecommand.exe")
    WScript.Sleep 1000000
    OExe.Terminate
    <Insert LogOff code>
    
    3 回复  |  直到 12 年前
        1
  •  2
  •   Andrew Cooper    16 年前

    类似的东西

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

    应该做这个把戏

        2
  •  2
  •   Pete Shalini Gupta    16 年前
    Wscript.Sleep(100000)  
    SET wshell = Wscript.CreateObject("Wscript.Shell")  
    wshell.exec("shutdown.exe -L -F")  
    

    刚在W7盒子上测试过这个,似乎可以用。

        3
  •  0
  •   wsware    16 年前

    使用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