Overblog Tous les blogs Top blogs Technologie & Science Tous les blogs Technologie & Science
Editer l'article Suivre ce blog Administration + Créer mon blog
MENU

VBS: Get ID of user Active

Publié le par damcuvelier

 

 

wscript.echo "user active = " & getidusract()

function getidusract()
dim objExecObject,strLine,i
    For i=1 to 100000
    Set objExecObject = WshShell.Exec("%comspec% /c qwinsta.exe " & i)
        Do Until objExecObject.StdOut.AtEndOfStream
        strLine = objExecObject.StdOut.ReadLine()
            If instr(lcase(strLine),lcase("Active")) > 0 _
            Or instr(lcase(strLine),lcase("Actif")) > 0 _
            Or instr(lcase(strLine),lcase("Actief")) > 0 _
            Or instr(lcase(strLine),lcase("Aktiv")) > 0 _
            Or instr(lcase(strLine),lcase("Activo")) > 0 _
            Or instr(lcase(strLine),lcase("Aktive")) > 0 _
            Or instr(lcase(strLine),lcase("???????")) > 0 Then
            getidusract= i
            exit for
            End If
        Loop
    Next
end function

Commenter cet article