2010-10-15 5 views
1

J'utilise un VBScript pour exécuter une application sur mon Win Server 2003, et je veux qu'il déconnecte l'utilisateur après un certain laps de temps. Quelque chose le long des lignes de:Comment se déconnecter de vbscript?

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

Répondre

2

Quelque chose comme

devrait faire l'affaire

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

testé ce juste une boîte de W7, semble fonctionner bien.

0

Exemple avec 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 
Questions connexes