diff --git a/docs/Options.md b/docs/Options.md
index 51b2927df25..92d8ba1207e 100644
--- a/docs/Options.md
+++ b/docs/Options.md
@@ -130,6 +130,7 @@ See [NSIS target notes](https://github.com/electron-userland/electron-builder/wi
| oneClick | One-click installation. Defaults to `true`.
| perMachine | Install per all users (per-machine). Defaults to `false`.
| allowElevation | *boring installer only.* Allow requesting for elevation. If false, user will have to restart installer with elevated permissions. Defaults to `true`.
+| runAfterFinish | *one-click installer only.* Run application after finish. Defaults to `true`.
| installerHeader | *boring installer only.* `MUI_HEADERIMAGE`, relative to the project directory. Defaults to `build/installerHeader.bmp`
| installerHeaderIcon | *one-click installer only.* The path to header icon (above the progress bar), relative to the project directory. Defaults to `build/installerHeaderIcon.ico` or application icon.
diff --git a/src/metadata.ts b/src/metadata.ts
index 1f40cfb4e7f..d4bab38c82c 100755
--- a/src/metadata.ts
+++ b/src/metadata.ts
@@ -372,6 +372,11 @@ export interface NsisOptions {
*/
readonly allowElevation?: boolean | null
+ /*
+ *one-click installer only.* Run application after finish. Defaults to `true`.
+ */
+ readonly runAfterFinish?: boolean | null
+
readonly guid?: string | null
/*
diff --git a/src/targets/nsis.ts b/src/targets/nsis.ts
index 430fd64ab9f..756e8fb3a0f 100644
--- a/src/targets/nsis.ts
+++ b/src/targets/nsis.ts
@@ -91,7 +91,12 @@ export default class NsisTarget extends Target {
defines.INSTALL_MODE_PER_ALL_USERS = null
}
- if (!oneClick && this.options.allowElevation !== false) {
+ if (oneClick) {
+ if (this.options.runAfterFinish !== false) {
+ defines.RUN_AFTER_FINISH = null
+ }
+ }
+ else if (this.options.allowElevation !== false) {
defines.MULTIUSER_INSTALLMODE_ALLOW_ELEVATION = null
}
diff --git a/templates/nsis/installer.nsi b/templates/nsis/installer.nsi
index 6ea28aea8d9..b423d2c6111 100644
--- a/templates/nsis/installer.nsi
+++ b/templates/nsis/installer.nsi
@@ -114,7 +114,9 @@ Section "install"
!ifdef ONE_CLICK
# otherwise app window will be in backround
HideWindow
- Call StartApp
+ !ifdef RUN_AFTER_FINISH
+ Call StartApp
+ !endif
!endif
SectionEnd
diff --git a/test/src/winPackagerTest.ts b/test/src/winPackagerTest.ts
index 14362d6802d..608c7f9de3b 100755
--- a/test/src/winPackagerTest.ts
+++ b/test/src/winPackagerTest.ts
@@ -34,12 +34,13 @@ test("nsis", () => assertPack("test-app-one", _signed({
}
))
-test.ifDevOrLinuxCi("nsis 32 perMachine", () => assertPack("test-app-one", {
+test.ifDevOrLinuxCi("nsis 32 perMachine, no run after finish", () => assertPack("test-app-one", {
targets: Platform.WINDOWS.createTarget(["nsis"], Arch.ia32),
devMetadata: {
build: {
nsis: {
perMachine: true,
+ runAfterFinish: false,
}
}
}