0

I use electron to convert my python-flask web application into a Desktop application. As installer, I use NSIS electron builder with a custom nsis script for the customer details page.

The issue is that the installer silently closes after choosing the installation option ("Admin user"/"Only for me").

It breaks on first installation attempt after building, in the 2nd attempt it works.

Customer details page:

enter image description here

User selection page: Breaking point

enter image description here

My NSIS setup:

nsis:
  oneClick: false
  perMachine: false
  allowElevation: false
  allowToChangeInstallationDirectory: true
  createDesktopShortcut: true
  createStartMenuShortcut: true
  shortcutName: FCC ValveSizing
  installerIcon: assets/FCC_Logo.ico
  uninstallerIcon: assets/FCC_Logo.ico
  deleteAppDataOnUninstall: true
  include: assets/installer.nsh
  language: 1033 # English
  installerSidebar: assets/installer_sidebar.bmp
  installerHeaderIcon: assets/FCC_Logo.ico
  differentialPackage: false

installer.nsh:

!include "MUI2.nsh"
!include "nsDialogs.nsh"
!include "LogicLib.nsh"
!include "FileFunc.nsh"
!insertmacro GetTime

!ifndef BUILD_UNINSTALLER
Var Dialog
Var NameInput
Var UserName
Var OriginalAppData
!endif

!macro customInit
    !ifndef BUILD_UNINSTALLER
        ReadRegStr $UserName HKCU "Software\FCCValveSizing\Setup" "UserName"
        ReadRegStr $OriginalAppData HKCU "Software\FCCValveSizing\Setup" "AppData"
        ${If} $OriginalAppData == ""
            StrCpy $OriginalAppData $APPDATA
        ${EndIf}
    !endif
!macroend

!macro customWelcomePage
    !ifndef BUILD_UNINSTALLER
        !ifdef MUI_WELCOMEPAGE_TITLE
            !undef MUI_WELCOMEPAGE_TITLE
        !endif
        !ifdef MUI_WELCOMEPAGE_TEXT
            !undef MUI_WELCOMEPAGE_TEXT
        !endif
        !define MUI_WELCOMEPAGE_TITLE "Welcome to FCC-ValveSizing Setup"
        !define MUI_WELCOMEPAGE_TEXT \
        "This installer will guide you through the installation of ValveSizing.$\r$\n\
        $\r$\n\
        Developed by FCCommune.$\r$\n\
        $\r$\n\
        Click Next to continue."

        !insertmacro MUI_PAGE_WELCOME
        !insertmacro MUI_PAGE_LICENSE "${BUILD_RESOURCES_DIR}\..\license.rtf"
        Page custom CustomerDetailsPage CustomerDetailsPageLeave
    !endif
!macroend

!ifndef BUILD_UNINSTALLER

Function CustomerDetailsPage
    !insertmacro MUI_HEADER_TEXT \
        "User Information" \
        "Enter your name to personalize your experience."

    nsDialogs::Create 1018
    Pop $Dialog

    ${If} $Dialog == error
        Abort
    ${EndIf}

    ${NSD_CreateLabel} 10u 10u 100u 12u "User Name:"
    Pop $R1

    ${NSD_CreateText} 10u 24u 220u 14u "$UserName"
    Pop $NameInput

    nsDialogs::Show
FunctionEnd

Function CustomerDetailsPageLeave
    ${NSD_GetText} $NameInput $UserName

    ${If} $UserName == ""
        MessageBox MB_OK|MB_ICONEXCLAMATION "Please enter your name before continuing."
        Abort
    ${EndIf}

    WriteRegStr HKCU "Software\FCCValveSizing\Setup" "UserName" "$UserName"
    WriteRegStr HKCU "Software\FCCValveSizing\Setup" "AppData" "$OriginalAppData"
FunctionEnd

!endif

!macro customInstall
    !ifndef BUILD_UNINSTALLER
        ${If} $UserName == ""
            ReadRegStr $UserName HKCU "Software\FCCValveSizing\Setup" "UserName"
        ${EndIf}
        ${If} $OriginalAppData == ""
            ReadRegStr $OriginalAppData HKCU "Software\FCCValveSizing\Setup" "AppData"
        ${EndIf}

        CreateDirectory "$OriginalAppData\ValveSizing"

        ${GetTime} "" "L" $0 $1 $2 $3 $4 $5 $6

        FileOpen $R0 "$OriginalAppData\ValveSizing\user.json" w
        FileWrite $R0 '{$\n'
        FileWrite $R0 '  "name": "$UserName",$\n'
        FileWrite $R0 '  "createdAt": "$2-$1-$0"$\n'
        FileWrite $R0 '}'
        FileClose $R0

        DeleteRegKey HKCU "Software\FCCValveSizing\Setup"
    !endif
!macroend

What could be causing this?

3
  • What do you mean by "the installer breaks"? Commented May 26 at 7:56
  • @mkrieger1 : the installer silently closes after choosing the installation option Commented May 26 at 8:14
  • Sounds like a crash, you probably need to ask the electron builder developers. If the electron builder people find the cause, they can report it upstream to NSIS if the bug is actually there... Commented Jun 5 at 17:41

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.