Reputation: 3046
I already posted a similar question (NSIS - check if registry key value exists) and the solution to that question worked perfectly:
ReadRegStr $0 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Ports" "NUL:"
And then:
${If} ${Errors}
#and so on
I do the same thing three more times in the script, reading different registry values and all attempts but the last one are successful:
ReadRegStr $3 HKLM "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Printers\SomePrinter" "Name"
This always returns an error.
What should I do differently?
The first time I read a registry value, I use $0
to store the return vale. Then the second time $1
and then $2
and $3
.
As I said, all work except for the last one. Does it have to do with the type of registry key I'm reading or should I use a different variable for the return value? I have tried other variables, but so far nothing has worked.
Thanks for help and tips!
Upvotes: 0
Views: 4820
Reputation: 11465
The problem with
ReadRegStr $3 HKLM "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Printers\SomePrinter" "Name"
is that you specify the root twice:
HKLM
HKEY_LOCAL_MACHINE\...
Remove the HKEY_LOCAL_MACHINE
from the sub key name and it should be OK. If you need to access another part of the registry, change the 2 parameter of ReadRegStr
as described in WriteRegExpandStr
manual section:
HKCR
for HKEY_CLASSES_ROOT
HKLM
for HKEY_LOCAL_MACHINE
HKCU
for HKEY_CURRENT_USER
HKU
for HKEY_USERS
HKCC
for HKEY_CURRENT_CONFIG
HKDD
for HKEY_DYN_DATA
HKPD
for HKEY_PERFORMANCE_DATA
SHCTX
for SHELL_CONTEXT
Upvotes: 4