Skip to content
⌘ NSIS Forum Archive

Default Install folder

10 posts

alibabavl64#

Default Install folder

I made an installer, let say InstApp1

InstallDir "C:\Path1"


For a new version of installer i made this:

Copied (Select All->CTRL+C) old installer instructions;
generate a new NSIS file, "Paste" in it instructions.
Modified what i need..Version and PATH:

InstallDir "C:\Path2".

Saved
generate installer, launch.

No metter on what PC launch installer, the default path still remain "C:\Path1".

Why happend this?

"C:\Path1" not found in NSIS source of second installer.
alibabavl64#
NSIS is installed about 3 years on XP SP3. And working well.
Installer tested on W7-64, XPSP3, W10-64..

On both the same wrong default install dir.


InstallDirRegKey HKLM "${PRODUCT_DIR_REGKEY}" ""

!define PRODUCT_DIR_REGKEY "Software\Microsoft\Windows\CurrentVersion\App Paths\LaunchPRG.exe"

Section -Post
WriteUninstaller "$INSTDIR\Uninstall.exe"
WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "" "$INSTDIR\LaunchPRG.exe
Anders#
The key path and/or name used in InstallDirRegKey must be different for different products because it overrides $InstDir set by InstallDir before .onInit.

Comment out the InstallDirRegKey line and see if that fixes the issue.
alibabavl64#
[...]

I will try to comment the line and i will tell you.

I saw now: If installed first version and not uninstalled, this key remain and became next Installdir...
I will erase the line.

Thank you
alibabavl64#edited
Please, more. You "lost" me.

Anyway, i commented the line as you told me and the default install path is showed correctly.
Nutzzz#
You probably already know this, but what @Anders was saying:

If your installer adds the uninstaller to the Add/Remove Programs (e.g., in reg key HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\LaunchPRG)

...then you would already be doing this on a new install:
WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\LaunchPRG" "InstallLocation" "$\"$INSTDIR$\""
[Which is what he meant by "applications unique Uninstall entry."]

Since you have to set that value anyway for the uninstaller, you should just use that for your upgrades:
InstallDir "$PROGRAMFILES64\LaunchPRG"  # set default
InstallDirRegKey HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\LaunchPRG" "InstallLocation" # get path for upgrade
You want to ensure the directory still exists before treating it as an upgrade. And of course you would make sure your uninstaller deletes that key.