Jump to content

Very Small Function ::: _Ash_UserKey_Detect


 Share

Recommended Posts

Hello

First:: My English is very bad, so I'm sorry :D

But I like this forum and AUtoIt :D

=============================

We are all exposed to the problem when dealing with this key :

HKEY_USERS\S-1-5-21-861567501-507921405-1202660629-1003

The reason is that changing from one system to another system

I made a small function

; #FUNCTION# ======================================
; Name...........: _Ash_UserKey_Detect
; Description ...: Detect User Key ,,, 
; Syntax.........: _Ash_UserKey_Detect ([$ReturnType = 0])
; Parameters ....: $ReturnType 
;                     0 = Return Only User Key 
;                     1 = Return All Path 
; Return values .: Success - Returns User Key
;                  Failure - none
; Author ........: Ashalshaikh - Ahmad Alshaikh
; ==============================================================
Func _Ash_UserKey_Detect ($ReturnType = 0)
    IF $ReturnType <0 Or $ReturnType >1 Then $ReturnType = 0
    $CountReg = 1
    Do
        $EnumKey = RegEnumKey ("HKEY_USERS",$CountReg )
        If @Error Then ExitLoop
        $CountReg= 1 + $CountReg
    Until StringLeft ($EnumKey,StringLen ("S-1-5-21")) =  "S-1-5-21"
    If $ReturnType = 0 Then 
        Return $EnumKey
    Else 
        Return "HKEY_USERS\" & $EnumKey
    EndIf
EndFuncoÝ÷ ØLZ^jëh×6#include "_Ash_UserKey_Detect.au3"
;With Nithing 
$UserKey = _Ash_UserKey_Detect () 
Msgbox (0,"","User Key Is : " & $UserKey)
;With 0
$UserKey = _Ash_UserKey_Detect (0) 
Msgbox (0,"","User Key Is : " & $UserKey)
;With 1
$UserKey = _Ash_UserKey_Detect (1) 
Msgbox (0,"","User Key Is : " & $UserKey)

Thank You

_Ash_UserKey_Detect.zip

Edited by Ashalshaikh
Link to comment
Share on other sites

Ashalshaikh - Please describe for me more perspicaciously exactly what this function has purpose to do - use any modern language.

i am sorry My English bad ,, but i try

always i meet this problem ,, when I Delete Or Edit Or Read Or Write With This Key

HKEY_USERS \S-1-5-21-861567501-507921405-1202660629-1003

because the

S-1-5-21-861567501-507921405-1202660629-1003

is not the same in all systems,, and you will notice that when comparing these on your system

cannot use S-1-5-21-861567501-507921405-1202660629-1003

because it will Not Exist In Other System ,, So will happen Error

For That I Made this function to Detect The

S-1-5-21-861567501-507921405-1202660629-1003

anywhere!!

Thank You

I Sory If Exist Wrongs In This Reply

Edited by Ashalshaikh
Link to comment
Share on other sites

Ashalshaikh - Thank you very much: you have succeeded completely in communicating what the function does.

I have not discovered why anyone should write to this key or read from it except to clean out the registry of unnecessary clutter. Probably you should use a key under HKEY_CURRENT_USER or HKEY_LOCAL_MACHINE instead.

Edited by Squirrely1

Das Häschen benutzt Radar

Link to comment
Share on other sites

Ashalshaikh - Thank you very much: you have succeeded completely in communicating what the function does.

I have not discovered why anyone should write to this key or read from it except to clean out the registry of unnecessary clutter. Probably you should use a key under HKEY_CURRENT_USER or HKEY_LOCAL_MACHINE instead.

Yes .. I Know

But ,,

There are lots of data and keys , you need to deal with It sometimes

Example

HKEY_USERS\S-1-5-21-861567501-507921405-1202660629-1003\Software

It's contains information about some programs ,, do not find in other

Thanks :D

Link to comment
Share on other sites

Yes .. I Know

But ,,

There are lots of data and keys , you need to deal with It sometimes

Example

HKEY_USERS\S-1-5-21-861567501-507921405-1202660629-1003\Software

It's contains information about some programs ,, do not find in other

Thanks :D

Ashalshaikh,

It's my understanding the keys should always be the same.

On my system, when I compare this key with HKEY_CURRENT_USER, all data is the same.

Verified by exporting both keys in their entirety, doing a replace of "[HKEY_USERS\S-1-5-21-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxx-xxxx" with "[HKEY_CURRENT_USER" within the HKEY_USERS\S-1-5-21-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxx-xxxx export, and then running a file comparison on both.

Link to comment
Share on other sites

Ashalshaikh,

It's my understanding the keys should always be the same.

On my system, when I compare this key with HKEY_CURRENT_USER, all data is the same.

Verified by exporting both keys in their entirety, doing a replace of "[HKEY_USERS\S-1-5-21-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxx-xxxx" with "[HKEY_CURRENT_USER" within the HKEY_USERS\S-1-5-21-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxx-xxxx export, and then running a file comparison on both.

Yes, but i mean you key

HKEY_USERS\S-1-5-21-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxx-xxxx

change from one computer to another,,

That's The Problem !!

If I Don't UnderStand You , I am Sorry .

Thank You

Link to comment
Share on other sites

Yes, but i mean you key

HKEY_USERS\S-1-5-21-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxx-xxxx

change from one computer to another,,

That's The Problem !!

If I Don't UnderStand You , I am Sorry .

Thank You

What I mean to say is that on any computer, the "HKEY_USERS\S-1-5-21-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxx-xxxx" key is the same as the "HKEY_CURRENT_USER" key on that computer, for the currently logged on user.

So if you want to read or write any info from/to "HKEY_USERS\S-1-5-21-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxx-xxxx" just read/write "HKEY_CURRENT_USER" on that computer instead.

Link to comment
Share on other sites

I did much the same here

#659946

and I have another one that uses the same key (HKU) to get all the user IDs from the same hive.

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

What I mean to say is that on any computer, the "HKEY_USERS\S-1-5-21-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxx-xxxx" key is the same as the "HKEY_CURRENT_USER" key on that computer, for the currently logged on user.

So if you want to read or write any info from/to "HKEY_USERS\S-1-5-21-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxx-xxxx" just read/write "HKEY_CURRENT_USER" on that computer instead.

That is new information for me

Thank you very much

:D

Link to comment
Share on other sites

I did much the same here

#659946

and I have another one that uses the same key (HKU) to get all the user IDs from the same hive.

Indeed,

Your Function works very well

My Function Us Sample , Because My Skill Is Semple :D

Thanks all of you

I learned something new today

:D;):P;):D:D

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