Archive: Different 'InstallDir's


Different 'InstallDir's
Hi everybody

From my component select dialogue the user can select all items
he wants to install. Than, he clicks on "next" and chooses the
destination folder.
So far, so good.

What I am looking for is the following:
If the user selects "ABC" he than choose the destination folder.
But "ABC" should go into a complete different folder and only in
the case he has selected "ABC" I want to have a *second* dialogue
where he can choose the destination for "ABC".

Is this possible ?
I have version 2.00b (or something very close to this)


Cheers
Uwe


SetOutPath
I'm not sure about how to code the logic to do exactly what you want, but a method which will help you is SetOutPath's. Different INSTDIR's will be ignored by the compiler. The first one listed will be the only one to work. SetOutPath's though can be put inside seperate functions.
So, build one function that installs "ABC" one way, and another function to install "BCD" another way. I personally love SetOutPath.

For example,

InstallDir 'C:\WINNT'

Section "-FSIWIN"
SetOutPath $INSTDIR
File /r 'C:\Documents and Settings\Administrator\Desktop\FSIWIN'
SectionEnd

Section "-WHITNEYAPP"
SetOutPath '$INSTDIR\FSIWIN\WHITNEY.APP\'
File 'C:\DOCUMENTS AND SETTINGS\ADMINISTRATOR\DESKTOP\WHITNEYAPP\*.*'
CreateShortCut '$DESKTOP\MultiBank.lnk' '$INSTDIR\FSIWIN\WHITNEY.APP\MultiBank.exe'
SectionEnd

This code pulls files from $DESKTOP\FSIWIN and dumps it (recursively) into the WINNT directory. It next pulls data from $DESKTOP\WHITNEYAPP and dumps it into the WINNT\FSIWIN\WHITNEY.APP folder.

You could take out the dashes in front of the Section names and make check boxes from them. Your user then could choose which data he wants to install. And you could choose where you want that data to go.
Again, I'm not really sure how to build the logic necessary to do everything you want, but I think this'll help.
Thanks,
Jacob


He wants a second directory selection dialog, not just to output to a specific directory.

What you need is InstallOptions. It allows you to create custom dialog pages. You can make a custom dialog with a directory selection box.


Can you fool NSIS, maybe use .onNextPage and .onPrevPage (yes I know the paging system has changed recently, but in versions which have .onBlah...) to reshow the choose folder dialog (I spose this relies on being able to store the previously chosen instdir into a variable, can that be done?) *or* can the new page system show the folder choice dialog twice?

Sunjammer


Hi,
thanks for your replies

Maybe I was not precise enough, yes, I need a *second* directory
selection dialog.

Thanks for the hint, i will try to figure out how
InstallOptions work -:)


Uwe


You can go back to the directory selection page, and you can show the same dialog twice. To change the text of the directory selection dialog you will have to use GetDlgItem and SendMessage. The only problem is it will save the new directory to the same $INSTDIR so you will have to save it in another variable. So, yes, it's another possible solution for this problem :D


HI

these few lines solved the problem for me (NSIS 2 Beta 3, modern UI):

;--------------------------------
!define MUI_CUSTOMPAGECOMMANDS ; i think you need this one
!define MUI_DIRECTORYPAGE
!define MUI_CUSTOMFUNCTION_DIRECTORY_SHOW DirectoryShow
!define MUI_CUSTOMFUNCTION_DIRECTORY_LEAVE DirectoryLeave
;--------------------------------
!insertmacro MUI_PAGECOMMAND_DIRECTORY ; due to MUI_CUSTOMPAGECOMMANDS
!insertmacro MUI_PAGECOMMAND_DIRECTORY ; you can call this one twice, but you need to !insertmacro your other pages too. Since I've got custom pages, it makes no difference for me.
;--------------------------------
; Tweak directory page
Function DirectoryShow
StrCmp $9 "1" ChangeDirectoryPage
StrCpy $9 "1" ; set state for next function entry
Goto EndDirectoryShow

ChangeDirectoryPage:
; change Directory page here for your second directory to query
StrCpy $9 "2" ; last state

EndDirectoryShow:
FunctionEnd
;--------------------------------
Function DirectoryLeave
StrCmp $9 "1" SaveInstallDir
StrCmp $9 "2" RestoreInstallDirAndSaveDatabaseDir
Goto EndDirectoryLeave

SaveInstallDir:
StrCpy $2 $INSTDIR ; store programm directory
Goto EndDirectoryLeave

RestoreInstallDirAndSaveDatabaseDir:
StrCpy $3 $INSTDIR ; store database directory
StrCpy $INSTDIR $2 ; restore programm directory

EndDirectoryLeave:
FunctionEnd
;--------------------------------

In the end you've got your directory in $3 and $INSTALLDIR contains the choosen programm directory.

Any suggestions to optimize this code are appreciated, since I don't really dig this script language.