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?
ReadRegStr $perMachineInstallationFolder HKLM "${INSTALL_REGISTRY_KEY}" InstallLocation is used to detect previous path.
So, if you want to set custom path,
WriteRegStr SHELL_CONTEXT "${INSTALL_REGISTRY_KEY}" InstallLocation "C:\MyApp"
can be used (note - not tested). A little bit hack, yes.
allowToChangeInstallationDirectory
not required in this case.
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
@hemavidal Can I change ${INSTALL_REGISTRY_KEY} to a String,Beacuse I wan't know the regedit path,when I change it, Program will not create uninstall panel record
@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:
Does anyone knows what variable to use such that i can set the $INSTDIR path as "C:\Users{CURRENT_USERNAME}"
Where {CURRENT_USERNAME} is the currently logged in username.
Thanks
Does anyone knows what variable to use such that i can set the $INSTDIR path as "C:\Users{CURRENT_USERNAME}"
Where {CURRENT_USERNAME} is the currently logged in username.
Thanks
I am also looking for this information
Does anyone knows what variable to use such that i can set the $INSTDIR path as "C:\Users{CURRENT_USERNAME}"
Where {CURRENT_USERNAME} is the currently logged in username.
ThanksI am also looking for this information
I'm not sure if you can set the $INSTDIR
But, you can use nsExec to call echo %homedrive%%homepath% to get the user's home directory, which is C:\Users\{CURRENT_USERNAME}
Hi @hemavidal , can you share how did you find
command StrCpy not valid outside Section or Function error.
I strarted installation file .exe it freezed, installation does not progress. I can't find I can see error logs
Most helpful comment
@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: