Skip to content
⌘ NSIS Forum Archive

Newbie -- conditionally setting Registry key

2 posts

aquarii#

Newbie -- conditionally setting Registry key

Newbie question here -- I want to make some Registry keys during my install, but if the keys already exist -- I don't want to overwrite the existing value. I've checked through the docs that come with the installer -- but I can't seem to find the right answer.
Lion King#
Re: Newbie -- conditionally setting Registry key

from bigtest.nsi example
ClearErrors
ReadRegStr $1 HKCR "software\microsoft" shit
IfErrors 0 NoError
MessageBox MB_OK "could not read from HKCR\software\microsoft\shit"
Goto ErrorYay
NoError:
MessageBox MB_OK "read '$1' from HKCR\software\microsoft\shit"
ErrorYay:
SectionEnd
this should work:
Section "Registry check"
ClearErrors
ReadRegStr $1 HKCU "software\microsoft" shit
IfErrors 0 NoError
WriteRegStr HKCU software\microsoft "shit" "0"
Goto ErrorYay
NoError:
MessageBox MB_OK "read '$1' from HKCU\software\microsoft\shit"
ErrorYay:
SectionEnd
without MessageBox:
Section "Registry check"
ClearErrors
ReadRegStr $1 HKCU "software\microsoft" shit
IfErrors 0 NoError
WriteRegStr HKCU software\microsoft "shit" "0"
NoError:
SectionEnd