Archive: using variables in ReadRegStr


using variables in ReadRegStr
I would like to use my own variables in ReadRegStr:

Var Test1
Var Test2
[...]
StrCpy $Test1 "HKLM"
StrCpy $Test2 "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"


Why does the following not work?

ReadRegStr $1 $Test1 $Test2 "PATH"


Whereas the following works:

ReadRegStr $1 "HKLM" $Test2 "PATH"



Thanks!


ReadRegStr doesn't process the root key on runtime. If you want to make it change on runtime you'd have to add another line of ReadRegStr. Same goes for all other registry instructions.


I would like to do the following:

In the function .onInit I check if the user has administration
rights, if so, I would like to register the environment variables
for all users, otherwise they are registered for the current user
(thus I have to use different root_key and sub_key for reading and writing the registry keys).

How could I achieve that?


A simple comparsion. Assuming $0 is set to "admin" if the user can write to HKLM you can use:

StrCmp $0 "admin" goHKLM
WriteRegStr HKCU ....
Goto done
goHKLM:
WriteRegStr HKLM ....
done: