0
votes

I am creating an electron app installer using electron-builder. I can change the default installation directory using a macro in build/installer.nsh as follows:

!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

This works for me and my app can install under C:\myApp .

However, I would like for it to install under C:\USER_HOME_DIR\myApp. I have tried using "$(HOME)\myApp", "${HOME}\myApp", "%HOME%\myApp" to no avail. I feel like I am missing something simple in how to reference the evironmental variable pointing to the user's home directory but don't know how.

Any help will be much appreciated.

Many thanks,

Arun

2

2 Answers

0
votes

In Windows the home folder location is in the %HOMEPATH% variable, not %HOME%. Try that instead.

0
votes

The NSIS constant for the user directory is: $PROFILE

So the following code should work:

!macro preInit
    SetRegView 64
    WriteRegExpandStr HKLM "${INSTALL_REGISTRY_KEY}" InstallLocation "$PROFILE\MyApp"
    WriteRegExpandStr HKCU "${INSTALL_REGISTRY_KEY}" InstallLocation "$PROFILE\MyApp"
    SetRegView 32
    WriteRegExpandStr HKLM "${INSTALL_REGISTRY_KEY}" InstallLocation "$PROFILE\MyApp"
    WriteRegExpandStr HKCU "${INSTALL_REGISTRY_KEY}" InstallLocation "$PROFILE\MyApp"
!macroend