I am trying to generate electron app.exe with the use of **electron-builder** and **nsis**, which should ask user input at time of installation.
Following is my **package.json**.
...
"build": {
"appId": "com.electron.test",
"productName": "test",
"win": {
"target": [
"nsis"
],
"icon": "assets/icon.ico"
},
"nsis": {
"warningsAsErrors": false,
"installerIcon": "assets/icon.ico",
"runAfterFinish": false,
"oneClick": false,
"perMachine": true,
"allowToChangeInstallationDirectory": true,
"installerHeader": "assets/installerHeader.bmp",
"include": "build/installer.nsh"
},
"mac": {
"category": "your.app.category.type"
}
}
...
I want to display custom page **Between** Select Location Page and Installation Progress Page.
Following is my **installer.nsh** which is create one custom page i.e. ask for user to input username and password.
!include "EnvVarUpdate.nsh"
!include "MUI2.nsh"
!include "nsDialogs.nsh"
!include "LogicLib.nsh"
Var Dialog
Var UserLabel
Var UserText
Var UserState
Var PassLabel
Var PassText
Var PassState
;--------------------------------
; Show install details
ShowInstDetails show
;--------------------------------
;Interface Settings
!define MUI_ABORTWARNING
Page custom nsDialogsPage nsDialogsPageLeave
Function nsDialogsPage
nsDialogs::Create 1018
Pop $Dialog
${If} $Dialog == error
Abort
${EndIf}
${NSD_CreateLabel} 0 0 100% 12u "Username:"
Pop $UserLabel
${NSD_CreateText} 0 13u 100% 12u $UserState
Pop $UserText
${NSD_CreateLabel} 0 39u 100% 12u "Password:"
Pop $PassLabel
${NSD_CreatePassword} 0 52u 100% 12u $PassState
Pop $PassText
nsDialogs::Show
FunctionEnd
Function nsDialogsPageLeave
${NSD_GetText} $UserText $UserState
${NSD_GetText} $PassText $PassState
${If} $UserState == ""
MessageBox MB_OK "Username is missing."
Abort
${EndIf}
${If} $PassState == ""
MessageBox MB_OK "Password is missing."
Abort
${EndIf}
StrCpy $1 $UserState
StrCpy $2 $PassState
FileOpen $9 $INSTDIR\credentials.txt w
FileWrite $9 "$1:$2"
FileClose $9
SetFileAttributes $INSTDIR\credentials.txt HIDDEN|READONLY
FunctionEnd
Section
SectionEnd
!macro customHeader
!macroend
!macro preInit
!macroend
!macro customInstall
${EnvVarUpdate} $0 "PATH" "A" "HKLM" "$INSTDIR"
!macroend
!macro customUnInstall
${un.EnvVarUpdate} $0 "PATH" "R" "HKLM" "$INSTDIR"
!macroend
Please provide any solution.
**Thanks & Regards**
Rachit V. Sakhidas