【问题标题】:How do I logout from vbscript?如何从 vbscript 注销?
【发布时间】:2010-10-15 00:22:46
【问题描述】:

我正在使用 VBScript 在我的 Win Server 2003 上运行应用程序,我希望它在一定时间后注销用户。大致如下:

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

【问题讨论】:

    标签: windows vbscript logoff


    【解决方案1】:

    有点像

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

    应该做的伎俩

    【讨论】:

      【解决方案2】:
      Wscript.Sleep(100000)  
      SET wshell = Wscript.CreateObject("Wscript.Shell")  
      wshell.exec("shutdown.exe -L -F")  
      

      刚刚在 w7 盒子上测试过,似乎可以正常工作。

      【讨论】:

        【解决方案3】:

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

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2021-01-24
          • 2017-12-31
          • 2015-08-07
          • 1970-01-01
          • 1970-01-01
          • 2012-11-17
          • 2012-08-16
          • 1970-01-01
          相关资源
          最近更新 更多