Jump to content

Anyone knows environmental variable for this ?


Recommended Posts

Take a look at picture i attached and see if you can help me to find some sort of environmental variable for selected KEY.

I noticed its different on each computer so i wonder if there is a way to get to it without knowing the number.

I mean all those keys go there somehow right ?

post-49108-1241244695_thumb.jpg

Link to comment
Share on other sites

That reg key always starts with the "S-1-5-21-" prefix, so you can use this code:

For $i= 1 to 20

    $var = RegEnumKey("HKEY_USERS\", $i)
    If StringInStr($var, "S-1-5-21-") > 0 and StringInStr($var, "classes") = 0 Then
        ExitLoop
    EndIf
        
Next

MsgBox(1, "MSG", $var)
Link to comment
Share on other sites

goal is simple, pull the key out even if the number is different (and it is different for different computer)

to blueforce:

SICK !!!!!!! ^_^ i love you man but i have no idea what you did and how it works but it works.

It will take me some time to figure out how this code works so i can change it to more smaller version.

Link to comment
Share on other sites

it's actually the user's SID

_Security__LookupAccountSid "user SID"

Return Value

Success: Array with the following format:
    $aAcct[0] - Account name
    $aAcct[1] - Domain name
    $aAcct[2] - SID type, which can be one of the following values:
    1 - Indicates a user SID
    2 - Indicates a group SID
    3 - Indicates a domain SID
    4 - Indicates an alias SID
    5 - Indicates a SID for a well-known group
    6 - Indicates a SID for a deleted account
    7 - Indicates an invalid SID
    8 - Indicates an unknown SID type
    9 - Indicates a SID for a computer
Failure: 0
Edited by DCCD
Link to comment
Share on other sites

hey blueforce, i am having problem deleting test key at the end of your script.

here is what i got after Next.

RegDelete ($var & "\test", "")
MsgBox(1, "MSG", $var)

What am i doing wrong ?

And if the key would have space in name, as if it was "test key" do i need to use ' ? and how ?

Thanks allot guys

Edited by stoopid
Link to comment
Share on other sites

  • Developers

DCCD, how do i use this SID finder ?

Can you give me an example ?

What about when you stop asking for examples and start looking at the helpfile and trying to sort out things yourself?

You cannot have been looking at it at all looking at the time between posts.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

#Include <Security.au3>
$aAcct = _Security__LookupAccountName(@ComputerName & "\" & @UserName)
;
TrayTip("Export SID Number...", $aAcct[0], 10, 1)
Sleep(6000)
TrayTip("Domain name...", $aAcct[1], 10, 2)
Sleep(6000)
TrayTip("SID type...", $aAcct[2], 10, 2)
Sleep(6000)

Link to comment
Share on other sites

From Jos

What about when you stop asking for examples and start looking at the helpfile and trying to sort out things yourself?

You cannot have been looking at it at all looking at the time between posts.

Jos

i do look at help file and i try many times before i post a question.

not everyone understands documentation, some ppl would rather ask for example.

If you would stop being an jackass, maybe your girlfriend would come back to you.

to DCCD

thank you very much

Edited by stoopid
Link to comment
Share on other sites

  • Developers

If you would stop being an jackass, maybe your girlfriend would come back to you.

I don't mind you not agreeing with me but will not allow these type of personal attacks.

You will have 3 days to think about that.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

When he gets back he'll find that searching the forums for SID would have turned this up in Example Scripts.

Get User SID

It's exactly what I wrote the function for.

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

Ok thank you all for your help.

Now i am still unable to figure out the use or the output for most of commands.

If SID is displayed by msgbox, then lets say i want to reed registry key from that SID, how do i change my code to regread to read it ?

#Include <Security.au3>
$sAccount = @UserName
$SID = _Security__LookupAccountName($sAccount)
MsgBox(4096, "Test", $SID[0])

RegRead ("????\Software", "")
if @error = -1 Then
    MsgBox (0,"","yes")
ElseIf @Error = 1 Then 
    MsgBox (0,"","no")
EndIf

I need to replace ??? with something that will read the SID output as directory input for reading registry key.

I dont want to type in the SID my self caz its different on any other computer ;)

Any suggestion is better than nothing.

Maybe i need to create a variation that represents the SID output as some kinda name that i could use with regread ? I have no clue ^_^

Thanks

Also in this very example, $SID[0] ? What does [0] do and where in help file i can find help on that ?

Edited by lessstoopid
Link to comment
Share on other sites

What do you mean? Do you want to check if the key exists or if it's empty?

Take this for example. You can use another method to enumerated it's sub-keys to see if it exists or not using RegEnumKey(). Forgive me if I'm totally wrong ;]:

#include <Security.au3>

Dim $aRet, $iRet

$aRet = _Security__LookupAccountName(@UserName)
If @error Then
    ConsoleWrite(_WinAPI_GetLastErrorMessage() & @LF)
    Exit
EndIf

$iRet = RegRead('HKU\' & $aRet[0] & '\Software\Microsoft\Windows NT\CurrentVersion\Winlogon', 'BuildNumber')
ConsoleWrite($iRet & @LF)
Edited by Authenticity
Link to comment
Share on other sites

1st your script wont show me anything ^_^

and yes and no i dont just want to check if the key exist or not.

I know it exist, the problem is to navigate regread to that registry directory.

As you can see in my script that i am trying to get SID and when it pops up i dont know how to tell regread that its there.

When SID is displayed by MsgBox, i need to tell regread to read it from there, but how ?

Link to comment
Share on other sites

after SID is diplayed, i need regread to read it somehow.

For example:

regread ("HKEY_USERS\S-1-5-21-515967899-2049750123-682003330-500\Software","")

where S-1-5-21-515967899-2049760794-682003330-500 is SID

#Include <Security.au3>
$sAccount = @UserName
$SID = _Security__LookupAccountName($sAccount)

gets the SID

RegRead ("$SID\Software","")

this code is not gonna work because SID\Software is not valid registry directory.

Question.

Its 1 single script

1st it reads my SID and then i want the RegRead to read registry key under that SID

How to make RegRead to be able to read SID from 1st code above?

Thanks for quick response

oh yeah

I am not trying to read the value here, but only to test if regread can actually read the key.

From this i can learn much more

Edited by lessstoopid
Link to comment
Share on other sites

The function return a string so it's just a simple concatenation task and assumptions.

After this:

#Include <Security.au3>
$sAccount = @UserName
$SID = _Security__LookupAccountName($sAccount)oÝ÷ ÚØb±«­¢+Ù¥´ÀÌØíÍIÐôII Ìäí!-TÀäÈìÌäìµÀìÀÌØíM%lÁtµÀìÌäìÀäÈíͽÑÝÉÌäì°ÌäìÌäì¤

should be valid, again if no error. Check the error code to see if the key exists.

Edited by Authenticity
Link to comment
Share on other sites

$sUser = _Reg_GetSID()
If $sUser Then MsgBox(0, "RESULTS", $sUser)
$sSoftKey = "HKU\" & $sUser & "\Software\"
MsgBox(0, "RESULTS", $sSoftKey)

Func _Reg_GetSID()
   Local $sKey = "HKU\", $sEntry, $iReg = 1, $sRegEx = "(?i)s-1-5-21-([\d|-]*)"
   While 1
      $sEntry = RegEnumKey($sKey, $iReg)
      If @Error Then ExitLoop
      $iReg += 1
      If NOT StringRegExp($sEntry, $sRegEx) Then ContinueLoop
      Local $aRegExp = StringRegExp($sEntry, $sRegEx, 1)
      Return $aRegExp[0]
   Wend
   Return False
EndFunc;<==> _Reg_GetSID()

Note that there was an error in the code I linked you too. It's fixed here. I'll fix the other one in a few minutes.

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

Dim $sRet = RegRead('HKU\' & $SID[0] & '\software', '')

was exact edit for my code that i needed.

THANKS Authenticity Thanks allllllllot !

I dont understand what Dim $sRet = is for but erasign it didnt make any difference, instead it made script smaller ^_^

Maybe one day i will need to understand the meaning of Dim $sRet = , but not today ;)

Correct me if i am wrong. Everything that starts with $ is variable ? as it could be any word ?

If so, than $sRet same as $var ?

Edited by lessstoopid
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...