Windows Scripting BLOG

Due to limited time working on this project this place is not intended to people who are new to scripting but much more for people who are already familiar with the VBS/WMI syntax.

Donnerstag, 17. Mai 2007

Getting currently logged on users SID (Security Identifier)

On Error Resume NextstrComputer="."

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_ComputerSystem",,48)
For Each objItem in colItems
nm = objItem.UserNameResult = InStrRev(nm, "\")
tre = len(nm)
tre1 = tre - ResultRes = right(nm,tre1)
Set colOS = objWMIService.ExecQuery("Select * from WIN32_UserAccount where Name="""& Res & """")
for each obj in colOS
WScript.Echo "Name: " & obj.Name & " /SID: " & obj.SID & ""
Next
next
'gets currently logged on users SID by Julian Ruf

Keine Kommentare: