question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

NSIS - Change $INSTDIR to a custom path

See original GitHub issue

Electron Builder - 19.22.1 Target - NSIS

I’m trying to change the default installation directory to custom(Ex: C:\MyApp) and remove default(C:\Program Files\MyApp). package.json

{
    "win": {
      "target": "NSIS",
      "icon": "build/icon.ico"
    },
    "nsis": {
      "oneClick": false,
      "allowElevation": true,
      "allowToChangeInstallationDirectory": true,
      "createDesktopShortcut": true,
      "include": "build/installer.nsh"
    }
}

I used !macro preInit, but didn’t work: build/installer.nsh

!macro preInit
  StrCpy $INSTDIR "C:\MyApp"
!macroend

error

command StrCpy not valid outside Section or Function

It is possible to change default installation do C:\MyApp even if installer have only in elevation mode?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

5reactions
Kelerchiancommented, Nov 5, 2018

@hemavidal @develar Just letting you know guys: This would make autoUpdate always install to “C:\MyApp” (or your designated default dir) It happens on electron-builder 20.4.1.

Steps to reproduce:

  1. Make to version of your app, e.g. v0.1.0 and v.0.1.1
  2. Install v0.1.0 on somewhere other than “C:\MyApp”, for example “C:\MyAppp”
  3. Let the autoupdate run.
  4. Autoupdate will install on “C:\MyApp”
3reactions
hemavidalcommented, Aug 24, 2017

I resolved with this:

!macro preInit
	SetRegView 64
	WriteRegExpandStr HKLM "${INSTALL_REGISTRY_KEY}" InstallLocation "C:\MyApp"
	WriteRegExpandStr HKCU "${INSTALL_REGISTRY_KEY}" InstallLocation "C:\MyApp"
	SetRegView 32
	WriteRegExpandStr HKLM "${INSTALL_REGISTRY_KEY}" InstallLocation "C:\MyApp"
	WriteRegExpandStr HKCU "${INSTALL_REGISTRY_KEY}" InstallLocation "C:\MyApp"
!macroend
Read more comments on GitHub >

github_iconTop Results From Across the Web

Change the default install folder in NSIS - Stack Overflow
But currently the automatic installation path is set as follows in the installer. C:\Program Files (x86)\myapplication. The installer script ...
Read more >
Path Manipulation - NSIS - SourceForge
Warning : this code will replace paths rather than append if the existing path exceeds the maximum string length in the NSIS build...
Read more >
How to select the installation directory? - NSIS Forums
I have tried with sample code with same 'Page Directory'. But in this case it is promptly asking the user for installation path....
Read more >
How to change installation directory path with command line ...
I want to silently install NSIS in D:\VLC. I can do that with old ... Old VLC installer can change installation directory with...
Read more >
NSIS - electron-builder
PORTABLE_EXECUTABLE_APP_FILENAME - sanitized app name to use in file paths. Common Questions¶. How do change the default installation directory to custom?
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found