Reputation: 1
I've figured out how to install a windows service that manages a server (server.exe) when the user install the app via the ElectronBuilder.exe created when I package the app.
However, the Windows Service does not start in the install. I had to manually go into services and then start it.
I can't seem to figure out whats wrong with my script and would appreciate someone taking a look! Thanks! (p.s. I assume this shoould be possible)
Here is installer.nsh found in ./build
!macro customInstall
DetailPrint "Installing DialogixService..."
; 1 Install service with NSSM, pointing to your Node-based EXE
ExecWait '"$INSTDIR\resources\assets\nssm.exe" install "DialogixService" "$INSTDIR\resources\assets\server.exe"'
; 2 Set the service to auto-start
ExecWait '"$INSTDIR\resources\assets\nssm.exe" set "DialogixService" Start SERVICE_AUTO_START'
; 3 Start the service
ExecWait '"$INSTDIR\resources\assets\nssm.exe" start "DialogixService"'
!macroend
!macro customUninstall
DetailPrint "Uninstalling DialogixService..."
; 1 Stop the service
ExecWait '"$INSTDIR\resources\assets\nssm.exe" stop "DialogixService"'
; 2 Remove the service
ExecWait '"$INSTDIR\resources\assets\nssm.exe" remove "DialogixService"'
!macroend
Here is my Electron-Builder package.json
{
"name": "Dialogix",
"productName": "Dialogix",
"version": "1.0.0",
"description": "Dialogix App",
"main": "main.js",
"scripts": {
"start": "electron .",
"make": "electron-builder"
},
"devDependencies": {
"electron": "34.0.1",
"electron-builder": "^25.1.8"
},
"dependencies": {
"electron-squirrel-startup": "^1.0.1"
},
"build": {
"appId": "Dialogix.com",
"productName": "Dialogix",
"directories": {
"output": "dist"
},
"icon": "./icon.ico",
"extraResources": [
"./assets",
"./public"
],
"nsis": {
"runAfterFinish": true,
"createDesktopShortcut": true,
"createStartMenuShortcut": true,
"shortcutName": "MyElectronApp",
"include": "build/installer.nsh",
"installerIcon": "./icon.ico",
"uninstallerIcon": "./icon.ico",
"installerHeaderIcon": "./icon.ico"
},
"win": {
"requestedExecutionLevel": "requireAdministrator"
}
}
}
Upvotes: 0
Views: 18