【发布时间】:2021-06-28 11:47:16
【问题描述】:
我们有一个电子应用程序,它使用自定义 nsis 脚本进行安装程序。虽然这可以正常工作,但由于某种原因,如果应用程序以静默模式安装,我无法触发应用程序自动启动。
如果应用程序安装正常(例如:双击.exe,它会自动启动),但是如果从命令行使用类似:
"installer.exe" /S
它似乎没有自动启动。
目前使用的安装程序脚本 (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
我尝试了不同的变体:
Function .onInstSuccess
IfSilent +2 0
Exec '"Absolute\Path\To\app.exe"'
FunctionEnd
或者,在 customInit 宏中设置类似:SetSilent normal 的内容会触发类似双击出现安装程序屏幕的 .exe 时的行为。
非常感谢任何想法或建议。
【问题讨论】:
标签: electron nsis electron-builder