Skip to content
⌘ NSIS Forum Archive

Question about setting the output path

3 posts

wrybread#

Question about setting the output path

I'm trying to let users browse to whatever folder they'd like to install a package, but my NSIS script keeps adding the directory name of InstallDir to their selection. For example, if my default InstallDir is set like this:

InstallDir "c:\test1234"

But the user browses to c:\pics, it will then try to install to c:\pics\test1234.

Is there a way to take the path they browse to, without appending the InstallDir (in other words, without the "test1234" subfolder in the above example)?

Here's my stripped down sample script:

;Include Modern UI
!include "MUI.nsh"

Name "Teste123"
OutFile "Test_Installer.exe"

;Default installation folder
InstallDir "c:\test1234"

;Pages
!insertmacro MUI_PAGE_DIRECTORY

;Installer Sections
Section "ASDF" SecDummy
SetOutPath "$INSTDIR"
SectionEnd
wrybread#
Eureka!

For anyone else who comes down this road, from the manual:

4.8.1.21 InstallDir

definstdir

Sets the default installation directory. See the variables section for variables that can be used to make this string (especially $PROGRAMFILES). Note that the part of this string following the last \ will be used if the user selects 'browse', and may be appended back on to the string at install time (to disable this, end the directory with a \ (which will require the entire parameter to be enclosed with quotes). If this doesn't make any sense, play around with the browse button a bit.
In other words, I needed to change this line:

InstallDir "c:\test1234"

To:

InstallDir "c:\test1234\"

Works great now. Thanks for pointing me in the right direction Stu.