Old 14th June 2013, 10:29   #1
gruntlord6
Junior Member
 
Join Date: Jul 2010
Posts: 14
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?
gruntlord6 is offline   Reply With Quote
Old 14th June 2013, 11:20   #2
jpderuiter
Major Dude
 
Join Date: Feb 2007
Posts: 672
http://nsis.sourceforge.net/Abort
jpderuiter is offline   Reply With Quote
Old 14th June 2013, 11:28   #3
gruntlord6
Junior Member
 
Join Date: Jul 2010
Posts: 14
Quote:
Originally Posted by jpderuiter View Post
Thanks for the help! That solves half my problem. Can you tell me how I would perform the check? I would imagine something like:
code:
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.
gruntlord6 is offline   Reply With Quote
Old 14th June 2013, 11:43   #4
jpderuiter
Major Dude
 
Join Date: Feb 2007
Posts: 672
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
jpderuiter is offline   Reply With Quote
Old 14th June 2013, 16:57   #5
gruntlord6
Junior Member
 
Join Date: Jul 2010
Posts: 14
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.
gruntlord6 is offline   Reply With Quote
Old 14th June 2013, 17:11   #6
jpderuiter
Major Dude
 
Join Date: Feb 2007
Posts: 672
Quote:
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.
code:
ReadRegStr $0 HKLM "Software\(My Application)" ""
IfErrors 0 +3
MessageBox MB_OK "You need (My Application) installed to use this installer."
Abort

jpderuiter is offline   Reply With Quote
Old 14th June 2013, 22:32   #7
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
Call ClearErrors before ReadRegStr as well in case you later add code which sets the error flag resulting in an incorrect Abort.

Stu
Afrow UK is offline   Reply With Quote
Old 17th June 2013, 11:35   #8
gruntlord6
Junior Member
 
Join Date: Jul 2010
Posts: 14
Quote:
Originally Posted by Afrow UK View Post
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.
gruntlord6 is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump