Skip to content
⌘ NSIS Forum Archive

How to get HKEY_USERS\S-1-5-21* into a variable

4 posts

papaimark#

How to get HKEY_USERS\S-1-5-21* into a variable

I don't know if I used the right words to search here and web but I couldn' find.
How can I get my computer's number into a $var to write in it?

I tried to write in HKLM but it doesn't go to HKU

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\S-1-5-21-4040892793-3383166624-2797674911-500 sid

Is this "sid" the number I want, written in other format (bin) ?

Thank you.
Anders#
The "Sid" value there is just the same as the key name (S-1...) so you can just use the key name (EnumRegKey can list them).

If you want to access the HKCU of other users, use https://nsis.sourceforge.io/EnumUsersReg
papaimark#
Thank you Anders,
EnumRegKey only list the keys, not the folders BUT I found it in the "EnumUsersReg.nsh".
It gives all the folders in there, exactly what I want.

Now the best part: working on it to give me only the folder I need.
Thank you again.
papaimark#
If it may help someone, it got simple.
I tested it in my computer and in 2 virtual machines (W732 and W764) and worked.

!include "EnumUsersReg.nsh"
Name EnumUsersReg
OutFile EnumUsersReg.exe
var viva
silentinstall silent

Section
${EnumUsersReg} CallbackFunction temp.key
SectionEnd

Function CallbackFunction
Pop $0
StrCpy $1 $0 8
StrCmp $1 "S-1-5-21" 0 Again
StrCpy $2 $0 "" -8
StrCmp $2 "_Classes" Again
StrCpy $viva $0
Again:
FunctionEnd

Section
MessageBox MB_OK|MB_topmost|MB_Iconexclamation "$viva"
Sectionend