Archive: Installing to two paths, help (script inside)


Installing to two paths, help (script inside)
What I want to do:
- Install my application to the path the user chooses (default $PROGRAMFILES\...)
- Install a Winamp plugin...
  - Winamp path should be autodetected (from registry uninst value) but still editable by the user
  - If a Winamp installation is not detected the user shall be given the choice to not install Winamp plugin OR select the path manually.

What I have:
See attached file.

What's wrong with what I have:
- Doesn't autodetect Winamp path (duh, since there's no code for that yet :))

- When you click "Browse" to locate the Winamp folder, the text in between of the window titlebar and the treeview says "Select the folder to install <app name> in"; which is of course wrong, it should say something along the lines of "Select the path to your Winamp installation:".

- When you select the Winamp folder NSIS as a "\<appname>" to the end of the path.

Help would be appreciated. I'm not too great with NSIS, I might add, so be gentle. ;)


Hmm, seems like the attachment got away when I previewed the post.


1. see example script "winamp plugin" at <nsis>\examples\
2. (i believe you're using MUI) see MUI readme -> page settings -> components page
3. just use $INSTDIR\<appname> in all the file commands or do a SetOutPath "$INSTDIR\<appname>" before copying any files.


OK, I'm getting somewhere now.

Only thing left is to ONLY display the page where you select the winamp directory (the second MUI_PAGE_DIRECTORY) if you've chosen to install the plugin on the components page.
If you choose not to install the plugin, you shouldn't be bothered with choosing where to not install it...
How would I do that? I've tried everything that has entered my mind without any luck.

Some snippets:


var WINAMPFOLDER

Function .onInit
StrCpy $WINAMPFOLDER "$PROGRAMFILES\Winamp" ; Default folder
FunctionEnd

!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_DIRECTORY ; Main directory

!define MUI_DIRECTORYPAGE_VARIABLE $WINAMPFOLDER
!insertmacro MUI_PAGE_DIRECTORY ; Winamp directory
; The above two lines should only execute when the user chooses in install the plugin. How?


Edit: I just noticed, the older problem when you click "Browse" in the second directory window still persists, in other words, the text is all wrong (not the MUI_DIRECTORYPAGE_TEXT_TOP, but the text in the browse dialog).
Also, it still forces an \<appname> to the end of the path you choose.

To skip a page, call Abort in its PRE function. To check if a section is selected, use:

Section "my section" MySection
...
Section

...

SectionGetFlags ${MySection} $R0
IntOp $R0 $R0 & ${SF_SELECTED}
StrCmp $R0 ${SF_SELECTED} ...

-Stu


To prevent the appending filename, put a backslash at the end of the path:

StrCpy $WINAMPFOLDER "$PROGRAMFILES\Winamp\"


Thanks for the help everybody!
I rewrote the script based on nsis.sourceforge.net/wiki/Two_installations_in_one_installer (thanks Afrow UK ;)).
That plus some reading around means that everything is now exactly like I want it to be.