Old 6th August 2021, 11:16   #1
Symbicort
Junior Member
 
Join Date: Aug 2021
Posts: 5
NSIS user selected install directory

Is it possible to force the user to have a specific install directory when they select their custom install directory on the directory page?

I'm using MUI2.

My default install dir is

code:
InstallDir "$PROGRAMFILES64\${PRODUCT_PUBLISHER}\${PRODUCT_NAME}"


I can see that the install will select the final value in this to become the top folder of the user selected directory. For example when I put in Test here. The top folder of the user selected directory will be test.

code:
InstallDir "$PROGRAMFILES64\${PRODUCT_PUBLISHER}\Test"


Is there a way to force this to include another folder so the user will have to have "${PRODUCT_PUBLISHER}\${PRODUCT_NAME}"



Also I super apologies if I have duplicated this thread, I could swear I created one earlier but it disappeared after I selected submit. First time poster.
Symbicort is offline   Reply With Quote
Old 6th August 2021, 11:41   #2
Symbicort
Junior Member
 
Join Date: Aug 2021
Posts: 5
Fix

Ok I'll be honest this was my first problem with the installer that I couldn't handle myself by scanning the docs and googling. So I probably posted in haste. I apologies, I have since found a fix.

Hopefully this will help somebody else.

ok so the first step I took was to do the following.

code:
Function .onVerifyInstDir
; Will add publisher and name to install dir regardless of location.
StrCpy $INSTDIR "$INSTDIR\${PRODUCT_PUBLISHER}\${PRODUCT_NAME}"
FunctionEnd



This worked for all directories but caused ${PRODUCT_NAME} to be repeated. So the next step was to add a backslash to the installdir. This doesnt affect the default installdir, just custom.

code:
InstallDir "$PROGRAMFILES64\${PRODUCT_PUBLISHER}\${PRODUCT_NAME}\"
Symbicort is offline   Reply With Quote
Old 6th August 2021, 22:13   #3
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,411
The ending \ behavior is documented in the InstallDir attribute part of the documentation.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Tags
nsis

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump