Archive: Function .onVerifyInstDir


Function .onVerifyInstDir
Hey guys. First off, thanks for all the help I received so far. My installer is almost complete.

I would like to use the .onVerifyInstDir function. However the code I’m using is causing the function to run every time the user changes even 1 letter of the install path. I would like it to only check the install dir. after they hit the "install" button, and return them to the Install Dir page to correct the path if not correct. Here is what I’m using:

;this is my directory page...
!insertmacro MUI_PAGE_DIRECTORY

;
;bunch of stuff here...
;

Function .onVerifyInstDir
IfFileExists "$INSTDIR\GPLoans\GPAdmin.exe" 0 NotInGP
goto End
NotInGP:
MessageBox MB_OK|MB_ICONEXCLAMATION "The installation directory you chose, $INSTDIR, is not valid, please choose another."
Abort
End:
FunctionEnd

I have read everything I can about .onVerifyInstDir in the help file and think that I’m missing something in regards to !ifdef, !ifndef, or gflag. However I just can't figure out these terms. Thanks for any help you all can lend.

Jnuw


You can't do that with Function .onVerifyInstDir but you can use the leave function of that directory page. I'll give examples for you:

- Modern UI:

Use !define MUI_PAGE_CUSTOMFUNCTION_LEAVE "function" before !insertmacro MUI_PAGE_DIRECTORY

- Default UI:

Use Page instfiles "" "" "function"

Where "function" is the leave function name. Example:

  !define MUI_PAGE_CUSTOMFUNCTION_LEAVE "DirectoryLeave"
!insertmacro MUI_PAGE_DIRECTORY

Function DirectoryLeave
IfFileExists "$INSTDIR\GPLoans\GPAdmin.exe" End
MessageBox MB_OK|MB_ICONEXCLAMATION "The installation directory you chose, $INSTDIR, is not valid, please choose another."
Abort
End:
FunctionEnd

deguix - You rule. That did the trick. I have not been this happy at work since pizza day. Thanks a bunch.