Create Windows registry entries while installing electron application using MSI installer

Viewed 356

I am creating MSI installer using electron-builder. While installing it on win10 machine, I need to create some windows registry entries. As per the electron-builder documentation, I have created Installer.nsh as follow:

!macro customInstall
  SetRegView 64
  WriteRegExpandStr HKLM SOFTWARE/MyApp/ProductName "" "Myapp"
  WriteRegExpandStr HKLM SOFTWARE/MyApp/Version "" "Version"
  WriteRegExpandStr HKLM SOFTWARE/MyApp/ProductCode "" "code"
  WriteRegExpandStr HKLM SOFTWARE/MyApp/InstallationPath "" "$INSTDIR"
!macroend

and Add file build/installer.nsh. Use include/script parameter with path build/installer.nsh in the electron-builder.json file. The issue is that it is not creating the windows registry entries.

1 Answers

I realize this is a very old question, but I encountered the same problem. In the event it helps someone in the future, this due to using / instead of \ in your registry paths. Changing to the following should resolve the problem:

!macro customInstall
  SetRegView 64
  WriteRegExpandStr HKLM SOFTWARE\MyApp\ProductName "" "Myapp"
  WriteRegExpandStr HKLM SOFTWARE\MyApp\Version "" "Version"
  WriteRegExpandStr HKLM SOFTWARE\MyApp\ProductCode "" "code"
  WriteRegExpandStr HKLM SOFTWARE\MyApp\InstallationPath "" "$INSTDIR"
!macroend
Related