Archive: NSIS Start Menu problem


NSIS Start Menu problem
Hi,

I'm writing an installer for an application that customers may want to install multiple times.

I'm trying to check the install directory and start menu folder to ensure that the customer does not overwrite an existing installation (they can't anyway as the installer has overwrite is set to off - but I want a visible warning and the ability to change the install dir)

I use the pre and leave functions with MUI to check the selected install dir and start menu folder. The former works fine - $INSTDIR gets the value of the selected install dir and the LEAVE function uses that in its test. However, but the start menu checks don't work as the path entered in the start menu dialog doesn't get written into the start menu variable (MUI_PAGE_STARTMENU page_id variable)

The attached file is a stripped down version of the installer - it's just intended to show the problem.

To test it:
1. Create a folder call Batch in the same folder as the script. Put a few files in it.
2. Compile the script
3. Run the resulting setup - the app gets installed in the default install dir and start menu folder.
4. Run the setup again.
5. If you specify the default install dir you'll get a warning.
6. Change the install dir - that works ok.
7. Specify the default start menu folder - again you get a warning.
8. Change the start menu folder. The changed value does not get picked up.
9. Click on the back button and then on the Next button. This time the value of the start menu folder is correctly picked up by the installer.

Am I doing something wrong?
If not, is there a workaround?

I tried an invisble custom installer page directly after the start menu page. This picked up the user-specified value of the start menu folder but I couldn't work out how to send the installer back to the start menu page (so user could reenter start menu folder value)

I also tried the getDlgValue to get the control id the page element that contains the start menu folder string - but there doesn't seem to be a method for reading the actual value when you know the control id.

Finally, had a look inside system.nsh in NSIS\Contrib\Modern UI. Can't see where the dialog value for the start menu folder is picked up.

Thanks,
Eoin


Got a workaround

1. Got the RelGotoPage function from http://nsis.sourceforge.net/Go_to_a_NSIS_page#Modern_UI

2. After the start menu page, created another MUI_PAGE_DIRECTORY page - and gave it a custom PRE function.
That PRE function looks like:

Function CheckStartMenuFolder

MessageBox MB_OK "Inventory type: $INVENTORY_TYPE"

ReadRegStr $1 "${STARTMENUPAGE_REGISTRY_ROOT}" "${STARTMENUPAGE_REGISTRY_KEY}" "${STARTMENUPAGE_REGISTRY_VALUENAME}"

MessageBox MB_OK "Selected Start Menu: $STARTMENU_FOLDER"
MessageBox MB_OK "Existing Start Menu folder: $1"

${if} $1 == $STARTMENU_FOLDER
MessageBox MB_OK "There is already an asset gateway using this Start Menu folder.$\nChoose another location for this installation or uninstall the existing gateway."
; Go back a page (to the start menu page)
StrCpy $R9 -1
Call RelGotoPage
Abort
${Else}
; Go forward a page (skip this page)
StrCpy $R9 1
Call RelGotoPage
Abort
${EndIf}
FunctionEnd

The extra MUI_PAGE_DIRECTORY page never appears. You either go back to the start menu page or forward to the next page.


Um, best not to use MUI_PAGE_DIRECTORY as the extra, invisible page. It seems to clear the install folder value entered earlier in the real, visible MUI_PAGE_DIRECTORY.

Switched to using MUI_PAGE_WELCOME instead. That works ok.


Just use Page Custom CustomDummy for an invisible page.

Stu


Ok - works nicely. Thanks!