Jump to content

Regread


Recommended Posts

Hello guys.

I wanne read a value from the regsiter.

its here: HKEY_USERS\S-1-5-21-3946333757-1766177318-2146914013-1000

but this value is always different: S-1-5-21-3946333757-1766177318-2146914013-1000

on my computer its : S-1-5-21-3946333757-1766177318-2146914013-1000

but on my other computer its :S-1-5-21-606747145-287218729-1801674531-500.

is there a way to get the right value.

that i can read it on every computer?

greetz Yucatan.

Link to comment
Share on other sites

There have been a couple of scrits released in Example Scripts to get the current users SID including one by myself. I'm not sure where my public copy of that function is right now. If I find it I'll post back here. In the meantime you can search the examples.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

I haven't found it yet but I threw this together and it should do what you want.

MsgBox(0, "SID", _UserSID())

Func _UserSID()
    Local $iStart = 0, $sVal
    Local $sReg = "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList"
    While 1
        $iStart += 1
        $sKey = RegEnumKey($sReg, $iStart)
        If @Error Then ExitLoop
        If StringMid($sKey, 7, 2) <> 21 Then ContinueLoop
        $sVal = RegRead($sReg & "\" & $sKey, "ProfileImagePath")
        If StringRegExpReplace($sVal, "^.+\\(.+)$", "$1") = @UserName Then Return $sKey
    WEnd
    Return SetError(1, 0, "No Match")
EndFunc   ;==>_UserSID

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

Just another quick solution using COM Objects:

Global $sUserName="username" ; <- change it with your user name

MsgBox(64,"SID for user " & $sUserName,_GetSID($sUserName))

Func _GetSID($sUser,$sDomain=@ComputerName,$sComputer=@ComputerName)
    $oWMIService = ObjGet("winmgmts:\\" & $sComputer & "\root\cimv2")
    $oAccount = $oWMIService.Get("Win32_UserAccount.Name='" & $sUser & "',Domain='" & $sDomain & "'")
    Return $oAccount.SID
EndFunc

Have a nice day

sahsanu

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...