Archive: Quit NSIS if REG Entry Not Present


Quit NSIS if REG Entry Not Present
I am not new to NSIS, but I am not familiar with most of the advanced functions. Right now, my installer reads the reg entry and sets it as the default install path, and shows the standard Instfiles page. What I want to be able to do, is run a check when the installer runs (oninit right?) that will check for that reg entry and display a dialogue if it is not found, and when it displays that dialogue, it should exit afterword. What is the best way to go about doing this?


http://nsis.sourceforge.net/Abort


Originally posted by jpderuiter
http://nsis.sourceforge.net/Abort
Thanks for the help! That solves half my problem. Can you tell me how I would perform the check? I would imagine something like:
Function onInit
If RegKey HKLM "Software\(My Application)" "" false:
MessageBox MB_OK "You need (My Application) installed to use this installer."
Abort
FunctionEnd


I hope I don't seem lazy, I would just like an example to work from.

Read the value from registry:
http://nsis.sourceforge.net/Docs/Chapter4.html#4.9.2.12

Check for errors:
http://nsis.sourceforge.net/Docs/Chapter4.html#4.9.4.9

Show Messagebox:
http://nsis.sourceforge.net/Docs/Chapter4.html#4.9.4.15


Originally posted by jpderuiter
Read the value from registry:
http://nsis.sourceforge.net/Docs/Chapter4.html#4.9.2.12

Check for errors:
http://nsis.sourceforge.net/Docs/Chapter4.html#4.9.4.9

Show Messagebox:
http://nsis.sourceforge.net/Docs/Chapter4.html#4.9.4.15
I am not to sure what exactly you are purposing. The Messagebox is indeed what I am looking for to do the text output, and that part is now taken care of. Not sure how I am supposed to utilize IfErrors with ReadRegStr to get my result. It would really help to give an example.

Originally Posted by 4.9.2.12 ReadRegStr The error flag will be set and $x will be set to an empty string ("") if the string is not present.
ReadRegStr $0 HKLM "Software\(My Application)" ""
IfErrors 0 +3
MessageBox MB_OK "You need (My Application) installed to use this installer."
Abort

Call ClearErrors before ReadRegStr as well in case you later add code which sets the error flag resulting in an incorrect Abort.

Stu


Originally posted by Afrow UK
Call ClearErrors before ReadRegStr as well in case you later add code which sets the error flag resulting in an incorrect Abort.

Stu
Thank you both! The installer now works as expected.