Archive: Best Practices


Best Practices
I have been reading the forum and the wiki for about a week now and still have a few questions about the best way to implement a few things as well as a few questions.

First off here is what I am doing. I am creating a custom dialog that gets some user input (select one of two options via radio button in a group box). Based on this I either delete a file or don't and then start an external MSI (wrapped in an exe).

I am having very sporadic and inconsistant results when reading the state of the the radio buttons. I think that this may be because I am saving the state in the post callback function of the custom page (is this too soon?). Here is the order of the pages.

!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_INSTFILES
Page custom SelectInstall runMSI
!insertmacro MUI_PAGE_FINISH

my SelectInstall looks like this.

Function SelectInstall
!insertmacro MUI_HEADER_TEXT "$(INSTALLOPS_TITLE)" "$(INSTALLOPS_SUBTITLE)"
!insertmacro MUI_INSTALLOPTIONS_DISPLAY "InstallOps"
!insertmacro MUI_INSTALLOPTIONS_READ $InstTypes "InstallOps" "Field 3" "State"
FunctionEnd

my runMSI looks like this

Function runMSI
StrCmp $InstTypes "1" 0 InstallUn
MessageBox MB_ICONINFORMATION|MB_OK "Running managed $InstTypes"
ExecWait '"$INSTDIR\setup.exe" '
Goto DoneInstall
InstallUn:
MessageBox MB_ICONINFORMATION|MB_OK "Running UnManaged $InstTypes"
Delete "$INSTDIR\GRC.DAT"
ExecWait '"$INSTDIR\setup.exe" '

DoneInstall:
Exec '"$INSTDIR\uninst.exe" /S'
FunctionEnd

This is where I am currently at. I am really excited about NSIS. I think it will be very useful if I can become proficient in it.

Ultimately I would like to know when it is most appropriate to run an external setup (and can the NSIS installer be minimized until the second installer finishes?)

Thanks


Well I solved the sporadic results of the radio button by moving the line

!insertmacro MUI_INSTALLOPTIONS_READ $InstTypes "InstallOps" "Field 3" "State"

to my runMSI function right before my StrCmp. (I am still what functions can be called from where).

However I am still curious to know anyone's opinion on the best practives for organization. Thanks.


As far as I know, the installoptions INI file does not actually get changed until an event happens to allow the DLL to write the info back to the INI file. Therefore, you always want to check for the state of the controls on the page's leave function (as you've probably figured out.)

You can also call an ABORT command in the page's leave function to prevent the next page from loading.

For more hints on proper organization, check out the example scripts contained in ${NSISDIR}\Examples\InstallOptions. Or, if using MUI, check out ${NSISDIR}\Examples\Modern UI.


Thanks