Archive: Check existence of registry key


Check existence of registry key
I want to build a package that, depending on the existence of a certain registry key, copies some files to a directory (also found in the registry) or just quits. This all very silent. Getting the InstallDIr from the registry is no problem, but I don't understand the codesnippit from the NSIS-archieve http://nsis.sourceforge.net/archive/...hp?pageid=307.

Can someone create a complete basic example of a ready2compile script. I think I can manage from there.


Do you really need to know whether it exits or is knowing whether it has a value enough?

In the first case, use the macro from that archive page:

!insertmacro IfKeyExists "ROOT" "KeyToCheckIn" "KeyToCheck"
Pop $R0
;$R0 contains 0 (not present) or 1 (present)

Otherwise, just compare the value form the key with "".

And after that use

StrCmp $R0 1 KeyFound KeyNotFound
KeyFound:
File bla.exe
etc...
KeyNotFound:


And put that all in a Section

easier:

Push $0
ClearErrors

ReadRegStr $0 ROOT "Your\Reg\Path" "YourKey"
IfErrors KeyDoesntExist KeyExists

KeyDoestnExist:
ClearErrors
# do something
Goto End

KeyExists:
# do something else

End:
Pop $0