Jump to content
Sign in to follow this  
microbious

Anyone knows environmental variable for this ?

Recommended Posts

microbious

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

Share this post


Link to post
Share on other sites
blakel

There is no environment variable set by windows on startup for that.

What is the end goal?

Share this post


Link to post
Share on other sites
blueforce4116

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)

Share this post


Link to post
Share on other sites
microbious

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.

Share this post


Link to post
Share on other sites
DCCD

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

Share this post


Link to post
Share on other sites
microbious

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

Share this post


Link to post
Share on other sites
microbious

DCCD, how do i use this SID finder ?

Can you give me an example ?

Share this post


Link to post
Share on other sites
Jos

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


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
DCCD

#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)

Share this post


Link to post
Share on other sites
microbious

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

Share this post


Link to post
Share on other sites
Jos

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


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
GEOSoft

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!"

Share this post


Link to post
Share on other sites
microbious

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

Share this post


Link to post
Share on other sites
Authenticity

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

Share this post


Link to post
Share on other sites
microbious

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 ?

Share this post


Link to post
Share on other sites
Authenticity

To read what? Empty value of the sub-key Software? Try again the code posted with different sub-key and value name, it should return something. Use MsgBox if you prefer, I use ConsoleWrite because it's less annoying...

Share this post


Link to post
Share on other sites
microbious

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

Share this post


Link to post
Share on other sites
Authenticity

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

Share this post


Link to post
Share on other sites
GEOSoft

$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!"

Share this post


Link to post
Share on other sites
microbious

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

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.