Archive: Choose between two directories


Choose between two directories
Hi,

I have been creating a installer for my firm, it have been a couple of months since i have been working on it, and now they have asked my to make some improvements to it.

At the moment the installer chooses it's install patch by the registry and it works perfectly, but some of the users there is trying to install do not have the patch in the registry, and therefore i have been asked to make it so that they have two options, install by default(by the patch in the registry) or by manually selecting the patch.

Is this something any of you can assist me with?

Best Regards
Aaskilde


Create a custom page with nsDialogs.

Stu


Hey Stu,

I have been trying to get an idea of how i need to write the code for creating what i have been asking about. But i can't get it to work.

I have been asked to edit an existing installer i have created, it takes a path from the registry database and install the files, but however some users who is in need of this installer have move the folders around and the path in the registry no longer works. But we do not know which users that have moved the folders and then we need two different path they can choose, the one should be default and locked maybe even just a click box, and then a way to select a folder manually to install the files.

Is they any of you there can help me get this working, i can't get the understanding of the code to get it going, so i really could use some help.

Aaskilde


If you just want to select a single directory, why not add a directory page? You can skip the directory page by calling Abort in its pre function if the registry value you read points to a valid directory.

Stu


Hey Stu,

What you say sounds perfect, if the value in the registry is valid the installer should continue, but if not you should could point at the path manually, that is what you want me to make right?

But i have not been using NSIS code that much and i really cant see how the code should be written.

This is what i have for my direction patch by the registry database:

Function InstallDirectory
!insertmacro MUI_HEADER_TEXT "Ready to install the program" "Below is the location where Neo.Dashboard will be installed"
nsDialogs::Create 1018
Pop $0

ReadRegStr $0 HKLM "SOFTWARE\Lotus\Domino\1" "DataPath"


${NSD_CreateLabel} 10u 0 100% 140u "Installing Neo.Dashboard 4.3a to:$\r$\n$\r$\n$0\Domino\html\$\r$\n$0\ \
$\r$\n$\r$\n$\r$\n$\r$\n$\r$\n$\r$\n$\r$\n$\n$\r$\n$\r$\nClick install to begin the installation.$\n$\r$\n$\rIf you want to review or change the installation, click Back.$\r$\nClick Cancel to exit the wizard."
Pop $0

nsDialogs::Show

FunctionEnd

How should i start writing the code in the way that you tell me?


You don't need to write a custom page for this. Just add a standard DIRECTORY page. See the MUI2 readme for details:
http://nsis.sourceforge.net/Docs/Mod...02/Readme.html


Hi MSG,

Okay i can see what you mean i have not used the directory page only my custom.

So now i have got my custom directory page and the standard directory page.

But let's say i need my custom directory page to be shown first and if the path in that is not found by the directory it should jump to the standard directory page so you manually can select where to install the files.

Is that something i can write in my custom directory page shown here?
____________________________________________________________________
Function InstallDirectory
!insertmacro MUI_HEADER_TEXT "Ready to install the program" "Below is the location where Neo.Dashboard will be installed"
nsDialogs::Create 1018
Pop $0

ReadRegStr $0 HKLM "SOFTWARE\Lotus\Domino\1" "DataPath"


${NSD_CreateLabel} 10u 0 100% 140u "Installing Neo.Dashboard 4.3 to:$\r$\n$\r$\n$0\Domino\html\$\r$\n$0\ \
$\r$\n$\r$\n$\r$\n$\r$\n$\r$\n$\r$\n$\r$\n$\n$\r$\n$\r$\nClick install to begin the installation.$\n$\r$\n$\rIf you want to review or change the installation, click Back.$\r$\nClick Cancel to exit the wizard."
Pop $0

nsDialogs::Show

FunctionEnd
___________________________________________________________________


Does that mean you don't want to show the custom page if the path is invalid? To jump over the directory page (if the path is valid) just add a PRE custom function and call Abort in it. For example:

!define MUI_PAGE_CUSTOMFUNCTION_PRE DirectoryPre
!insertmacro MUI_PAGE_DIRECTORY

Function DirectoryPre
${If} ${FileExists} $INSTDIR\*.*
Abort
${EndIf}
FunctionEnd
I have used $INSTDIR but use whatever Var you have used. You don't need to use $0 for your ReadRegStr; you can read into $INSTDIR. In fact, that is what InstallDirRegKey is for.

Stu