http://www.petri.co.il/forums/showthread.php?t=21332
reprinted here for convenience
' www.petri.co.il/forums/showthread.php?p=61469#post61469
Const HKEY_USERS = &H80000003
strComputer = "." '<-- name of remote computer
Set objWMIService = GetObject( _
"winmgmts:{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")
Set Users = objWMIService.InstancesOf ("Win32_ComputerSystem")
for each User in Users
logonname = User.UserName
strUsr = Split(logonname,"\")(1)
strDomain = Split(logonname,"\")(0)
exit For
next
set colAccounts = objWMIService.ExecQuery _
("select * From Win32_UserAccount where " _
& "name = '" & strUsr & "' AND domain = '" & strDomain & "'")
For each objAccount in colAccounts
strSID = objAccount.SID
exit For
Next
wsh.echo "HKU-path for", logonname, vbNewLine & "HKEY_USERS\" & strSID & "\..."
OUTPUT
C:\WINDOWS>user.vbs
Microsoft (R) Windows Script Host Version 5.7
Copyright (C) Microsoft Corporation. All rights reserved.
HKU-path for DOMAIN\sodo
HKEY_USERS\S-1-5-11-7177352686-8047241297-547765659-67771
Cool. Alternatively, in PowerShell:
ReplyDeletePS> $user = New-Object System.Security.Principal.NTAccount("guest")
PS> $user.Translate([System.Security.Principal.SecurityIdentifier]).Value
S-1-5-21-4136385708-3597605771-3440172066-501
Thanks dude!
ReplyDeleteHad to use this again..nice, simple method!
ReplyDeleteHow about in windows 7? This works fine for XP but not for 7.
ReplyDeleteNot sure. Sadly, my company is still on XP!
ReplyDelete