Reputation: 2058
We have a electron app that uses a custom nsis script for installer. While that works as it should, for some reason, I'm not able to trigger the app to auto start if its installing in Silent mode.
If the app is installed normally (e.g: double click on .exe
, it starts automatically), however if used from command line something like:
"installer.exe" /S
It doesn't seem to start automatically.
Installer script so far used (installer.nsh
):
!macro preInit
SetRegView 64 ... some reg things -- OK
SetRegView 32 ... some reg things -- OK
!macroend
!macro customInit
; SHUT DOWN APP IF CURRENTLY RUNNING
${GetProcessInfo} 0 $0 $1 $2 $3 $4
${if} $3 != "${APP_EXECUTABLE_FILENAME}"
${nsProcess::FindProcess} "${APP_EXECUTABLE_FILENAME}" $R0
${If} $R0 == 0
;MessageBox MB_OK "App currently running - going to shutdown to install new version"
${nsProcess::CloseProcess} "${APP_EXECUTABLE_FILENAME}" $R0
Sleep 5000
${nsProcess::KillProcess} "${APP_EXECUTABLE_FILENAME}" $R0
Sleep 3000
${EndIf}
${nsProcess::Unload}
${endIf}
; Workaround for installer handing when the app directory is removed manually
${ifNot} ${FileExists} "$INSTDIR"
DeleteRegKey HKCU ...other reg thing
${EndIf}
!macroend
---the culprit---
Function .onInstSuccess
IfSilent +2 0
Exec '"$INSTDIR\app.exe"'
FunctionEnd
I have tried a different variation with:
Function .onInstSuccess
IfSilent +2 0
Exec '"Absolute\Path\To\app.exe"'
FunctionEnd
Alternatively, setting something like: SetSilent normal
in that customInit
macro, triggers the behaviour like when double clicking on the .exe
, where the installer screen appears.
Any ideas or suggestions are much appreciated.
Upvotes: 1
Views: 2974
Reputation: 2058
Since the app is built with electron along-side electron builder, even if custom .nsh file is provided, the app should still not start if installed in manual mode, as pointed out here.
After a bit of research, that feature can be enabled back, if provided in the command line params as such (pointed out here)
myAppInstaller.exe /S --force-run
Upvotes: 3
Reputation: 101559
IfSilent +2 0
skips the Exec
if the installer is silent! Just remove that line.
Silent installers don't usually start the app so ideally you should not change anything.
Upvotes: 1