From 38b4abe278e64fd8d679d75cf94bbecdee5e72bb Mon Sep 17 00:00:00 2001 From: Tony Date: Thu, 30 May 2024 13:24:10 +0800 Subject: [PATCH 01/11] Set shortcut target instead of re-create shortcuts --- .../bundle/windows/templates/installer.nsi | 45 +++++++++---------- .../src/bundle/windows/templates/utils.nsh | 15 +++++++ 2 files changed, 36 insertions(+), 24 deletions(-) diff --git a/tooling/bundler/src/bundle/windows/templates/installer.nsi b/tooling/bundler/src/bundle/windows/templates/installer.nsi index f2f14d1b3b25..092eeead4d3b 100644 --- a/tooling/bundler/src/bundle/windows/templates/installer.nsi +++ b/tooling/bundler/src/bundle/windows/templates/installer.nsi @@ -347,7 +347,7 @@ Var AppStartMenuFolder !define MUI_FINISHPAGE_SHOWREADME_FUNCTION CreateDesktopShortcut ; Show run app after installation. !define MUI_FINISHPAGE_RUN "$INSTDIR\${MAINBINARYNAME}.exe" -!define MUI_PAGE_CUSTOMFUNCTION_PRE SkipIfPassiveButUpdateShortcutIfUpdate +!define MUI_PAGE_CUSTOMFUNCTION_PRE SkipIfPassive !insertmacro MUI_PAGE_FINISH ; Uninstaller Pages @@ -590,6 +590,8 @@ Section Install Call CreateDesktopShortcut shortcut_done: + Call MigrateProductNameExeShortcuts + !ifdef NSIS_HOOK_POSTINSTALL !insertmacro "${NSIS_HOOK_POSTINSTALL}" !endif @@ -727,22 +729,25 @@ Function SkipIfPassive ${IfThen} $PassiveMode = 1 ${|} Abort ${|} FunctionEnd -Function SkipIfPassiveButUpdateShortcutIfUpdate - ${If} $PassiveMode = 1 - Call CreateDesktopShortcut - Abort +Function CreateStartMenuShortcut + ; Skip creating shortcut if in update mode or no shortcut mode + ${If} $UpdateMode = 1 + Return ${EndIf} + ${If} $NoShortcutMode = 1 + Return + ${EndIf} + + CreateDirectory "$SMPROGRAMS\$AppStartMenuFolder" + CreateShortcut "$SMPROGRAMS\$AppStartMenuFolder\${PRODUCTNAME}.lnk" "$INSTDIR\${MAINBINARYNAME}.exe" + !insertmacro SetLnkAppUserModelId "$SMPROGRAMS\$AppStartMenuFolder\${PRODUCTNAME}.lnk" FunctionEnd Function CreateDesktopShortcut - ; Skip creating shortcut if in update mode - ; and shortcuts doesn't exist, which means user deleted it - ; so we respect that. + ; Skip creating shortcut if in update mode or no shortcut mode ${If} $UpdateMode = 1 - IfFileExists "$DESKTOP\${PRODUCTNAME}.lnk" +2 0 - Return + Return ${EndIf} - ${If} $NoShortcutMode = 1 Return ${EndIf} @@ -751,19 +756,11 @@ Function CreateDesktopShortcut !insertmacro SetLnkAppUserModelId "$DESKTOP\${PRODUCTNAME}.lnk" FunctionEnd -Function CreateStartMenuShortcut - ; Skip creating shortcut if in update mode. - ; See `CreateDesktopShortcut` above. - ${If} $UpdateMode = 1 - IfFileExists "$SMPROGRAMS\$AppStartMenuFolder\${PRODUCTNAME}.lnk" +2 0 - Return +Function MigrateProductNameExeShortcuts + ${If} ${FileExists} "$SMPROGRAMS\$AppStartMenuFolder\${PRODUCTNAME}.lnk" + SetShortcutTarget "$SMPROGRAMS\$AppStartMenuFolder\${PRODUCTNAME}.lnk" "$INSTDIR\${MAINBINARYNAME}.exe" ${EndIf} - - ${If} $NoShortcutMode = 1 - Return + ${If} ${FileExists} "$DESKTOP\${PRODUCTNAME}.lnk" + SetShortcutTarget "$DESKTOP\${PRODUCTNAME}.lnk" "$INSTDIR\${MAINBINARYNAME}.exe" ${EndIf} - - CreateDirectory "$SMPROGRAMS\$AppStartMenuFolder" - CreateShortcut "$SMPROGRAMS\$AppStartMenuFolder\${PRODUCTNAME}.lnk" "$INSTDIR\${MAINBINARYNAME}.exe" - !insertmacro SetLnkAppUserModelId "$SMPROGRAMS\$AppStartMenuFolder\${PRODUCTNAME}.lnk" FunctionEnd diff --git a/tooling/bundler/src/bundle/windows/templates/utils.nsh b/tooling/bundler/src/bundle/windows/templates/utils.nsh index 6679d748ed0c..e27c95a61549 100644 --- a/tooling/bundler/src/bundle/windows/templates/utils.nsh +++ b/tooling/bundler/src/bundle/windows/templates/utils.nsh @@ -116,3 +116,18 @@ ${IUnknown::Release} $0 "" ${EndIf} !macroend + +; Set target path for a .lnk shortcut +!macro SetShortcutTarget shortcut target + !insertmacro ComHlpr_CreateInProcInstance ${CLSID_ShellLink} ${IID_IShellLink} r0 "" + ${If} $0 P<> 0 + ${IUnknown::QueryInterface} $0 '("${IID_IPersistFile}",.r1)' + ${If} $1 P<> 0 + ${IPersistFile::Load} $1 '("${shortcut}", ${STGM_READWRITE})' + ${IShellLink::SetPath} $0 '(w "${target}")' + ${IPersistFile::Save} $1 '("${shortcut}",1)' + ${IUnknown::Release} $1 "" + ${EndIf} + ${IUnknown::Release} $0 "" + ${EndIf} +!macroend From aa125dce66f61a94032f744e892b127fbdc93369 Mon Sep 17 00:00:00 2001 From: Tony Date: Thu, 30 May 2024 13:25:26 +0800 Subject: [PATCH 02/11] Comment --- tooling/bundler/src/bundle/windows/templates/installer.nsi | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tooling/bundler/src/bundle/windows/templates/installer.nsi b/tooling/bundler/src/bundle/windows/templates/installer.nsi index 092eeead4d3b..ea9ab5aa3fe9 100644 --- a/tooling/bundler/src/bundle/windows/templates/installer.nsi +++ b/tooling/bundler/src/bundle/windows/templates/installer.nsi @@ -590,6 +590,8 @@ Section Install Call CreateDesktopShortcut shortcut_done: + ; We used to use product name as MAINBINARYNAME + ; migrate old shortcuts to target the new MAINBINARYNAME name Call MigrateProductNameExeShortcuts !ifdef NSIS_HOOK_POSTINSTALL From 9fa90c1cc176b83f60f16b82dcfe9a83c6985aa3 Mon Sep 17 00:00:00 2001 From: Tony Date: Thu, 30 May 2024 13:28:46 +0800 Subject: [PATCH 03/11] Add change file --- .changes/nsis-migrate-shortcut.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changes/nsis-migrate-shortcut.md diff --git a/.changes/nsis-migrate-shortcut.md b/.changes/nsis-migrate-shortcut.md new file mode 100644 index 000000000000..c5370f1aa240 --- /dev/null +++ b/.changes/nsis-migrate-shortcut.md @@ -0,0 +1,5 @@ +--- +"tauri-bundler": "patch:bug" +--- + +Migrate old shortcuts by setting the path only instead of re-creating a new one From 48a75c0c8e3e6ec10e5924836250aeac58a428b8 Mon Sep 17 00:00:00 2001 From: Tony Date: Thu, 30 May 2024 13:29:37 +0800 Subject: [PATCH 04/11] re word change file --- .changes/nsis-migrate-shortcut.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changes/nsis-migrate-shortcut.md b/.changes/nsis-migrate-shortcut.md index c5370f1aa240..7b2ec16fe9ca 100644 --- a/.changes/nsis-migrate-shortcut.md +++ b/.changes/nsis-migrate-shortcut.md @@ -2,4 +2,4 @@ "tauri-bundler": "patch:bug" --- -Migrate old shortcuts by setting the path only instead of re-creating a new one +For NSIS installer, migrate old shortcuts by setting the path only instead of re-creating a new one From 6531eef07a05e8de489579541071d83da67ade4a Mon Sep 17 00:00:00 2001 From: Tony Date: Thu, 30 May 2024 13:39:31 +0800 Subject: [PATCH 05/11] Migrate before other shortcut creations --- .../bundler/src/bundle/windows/templates/installer.nsi | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tooling/bundler/src/bundle/windows/templates/installer.nsi b/tooling/bundler/src/bundle/windows/templates/installer.nsi index ea9ab5aa3fe9..64a314f14fb7 100644 --- a/tooling/bundler/src/bundle/windows/templates/installer.nsi +++ b/tooling/bundler/src/bundle/windows/templates/installer.nsi @@ -577,6 +577,10 @@ Section Install WriteRegDWORD SHCTX "${UNINSTKEY}" "NoRepair" "1" WriteRegDWORD SHCTX "${UNINSTKEY}" "EstimatedSize" "${ESTIMATEDSIZE}" + ; We used to use product name as MAINBINARYNAME + ; migrate old shortcuts to target the new MAINBINARYNAME name + Call MigrateProductNameExeShortcuts + ; Create start menu shortcut !insertmacro MUI_STARTMENU_WRITE_BEGIN Application Call CreateStartMenuShortcut @@ -590,10 +594,6 @@ Section Install Call CreateDesktopShortcut shortcut_done: - ; We used to use product name as MAINBINARYNAME - ; migrate old shortcuts to target the new MAINBINARYNAME name - Call MigrateProductNameExeShortcuts - !ifdef NSIS_HOOK_POSTINSTALL !insertmacro "${NSIS_HOOK_POSTINSTALL}" !endif From b9b9c700370cda44f9a8d4ebb77f01628096e32c Mon Sep 17 00:00:00 2001 From: Tony Date: Thu, 30 May 2024 13:40:47 +0800 Subject: [PATCH 06/11] Clean up --- tooling/bundler/src/bundle/windows/templates/installer.nsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tooling/bundler/src/bundle/windows/templates/installer.nsi b/tooling/bundler/src/bundle/windows/templates/installer.nsi index 64a314f14fb7..3aa2e80bbe18 100644 --- a/tooling/bundler/src/bundle/windows/templates/installer.nsi +++ b/tooling/bundler/src/bundle/windows/templates/installer.nsi @@ -578,7 +578,7 @@ Section Install WriteRegDWORD SHCTX "${UNINSTKEY}" "EstimatedSize" "${ESTIMATEDSIZE}" ; We used to use product name as MAINBINARYNAME - ; migrate old shortcuts to target the new MAINBINARYNAME name + ; migrate old shortcuts to target the new MAINBINARYNAME Call MigrateProductNameExeShortcuts ; Create start menu shortcut From 8259894fe1712e8dd666b51de5434250b0496fcb Mon Sep 17 00:00:00 2001 From: Tony Date: Thu, 30 May 2024 13:56:03 +0800 Subject: [PATCH 07/11] Fix missing !insertmacro --- tooling/bundler/src/bundle/windows/templates/installer.nsi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tooling/bundler/src/bundle/windows/templates/installer.nsi b/tooling/bundler/src/bundle/windows/templates/installer.nsi index 3aa2e80bbe18..29a6e3ffd819 100644 --- a/tooling/bundler/src/bundle/windows/templates/installer.nsi +++ b/tooling/bundler/src/bundle/windows/templates/installer.nsi @@ -760,9 +760,9 @@ FunctionEnd Function MigrateProductNameExeShortcuts ${If} ${FileExists} "$SMPROGRAMS\$AppStartMenuFolder\${PRODUCTNAME}.lnk" - SetShortcutTarget "$SMPROGRAMS\$AppStartMenuFolder\${PRODUCTNAME}.lnk" "$INSTDIR\${MAINBINARYNAME}.exe" + !insertmacro SetShortcutTarget "$SMPROGRAMS\$AppStartMenuFolder\${PRODUCTNAME}.lnk" "$INSTDIR\${MAINBINARYNAME}.exe" ${EndIf} ${If} ${FileExists} "$DESKTOP\${PRODUCTNAME}.lnk" - SetShortcutTarget "$DESKTOP\${PRODUCTNAME}.lnk" "$INSTDIR\${MAINBINARYNAME}.exe" + !insertmacro SetShortcutTarget "$DESKTOP\${PRODUCTNAME}.lnk" "$INSTDIR\${MAINBINARYNAME}.exe" ${EndIf} FunctionEnd From 7bb59df6da440d6900ca80284653f64c1b0063d2 Mon Sep 17 00:00:00 2001 From: Tony <68118705+Legend-Master@users.noreply.github.com> Date: Fri, 31 May 2024 08:12:00 +0800 Subject: [PATCH 08/11] Update .changes/nsis-migrate-shortcut.md Co-authored-by: Amr Bashir --- .changes/nsis-migrate-shortcut.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changes/nsis-migrate-shortcut.md b/.changes/nsis-migrate-shortcut.md index 7b2ec16fe9ca..a6cc84d27241 100644 --- a/.changes/nsis-migrate-shortcut.md +++ b/.changes/nsis-migrate-shortcut.md @@ -1,5 +1,5 @@ --- -"tauri-bundler": "patch:bug" +"tauri-bundler": "patch:enhance" --- For NSIS installer, migrate old shortcuts by setting the path only instead of re-creating a new one From 040289ea52467c423bd895026d891553409e862a Mon Sep 17 00:00:00 2001 From: Tony Date: Fri, 31 May 2024 08:51:34 +0800 Subject: [PATCH 09/11] Use or if --- .../bundler/src/bundle/windows/templates/installer.nsi | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/tooling/bundler/src/bundle/windows/templates/installer.nsi b/tooling/bundler/src/bundle/windows/templates/installer.nsi index 29a6e3ffd819..83d3328d42c4 100644 --- a/tooling/bundler/src/bundle/windows/templates/installer.nsi +++ b/tooling/bundler/src/bundle/windows/templates/installer.nsi @@ -734,9 +734,7 @@ FunctionEnd Function CreateStartMenuShortcut ; Skip creating shortcut if in update mode or no shortcut mode ${If} $UpdateMode = 1 - Return - ${EndIf} - ${If} $NoShortcutMode = 1 + ${OrIf} $NoShortcutMode = 1 Return ${EndIf} @@ -748,9 +746,7 @@ FunctionEnd Function CreateDesktopShortcut ; Skip creating shortcut if in update mode or no shortcut mode ${If} $UpdateMode = 1 - Return - ${EndIf} - ${If} $NoShortcutMode = 1 + ${OrIf} $NoShortcutMode = 1 Return ${EndIf} From 5de3370444d7864ff30cbbc913fd73fcf97c1ed2 Mon Sep 17 00:00:00 2001 From: Tony Date: Fri, 31 May 2024 16:28:29 +0800 Subject: [PATCH 10/11] Put migrate code in create function also updates some jumps to if else --- .../bundle/windows/templates/installer.nsi | 78 ++++++++++--------- 1 file changed, 42 insertions(+), 36 deletions(-) diff --git a/tooling/bundler/src/bundle/windows/templates/installer.nsi b/tooling/bundler/src/bundle/windows/templates/installer.nsi index 83d3328d42c4..1cb66d230374 100644 --- a/tooling/bundler/src/bundle/windows/templates/installer.nsi +++ b/tooling/bundler/src/bundle/windows/templates/installer.nsi @@ -344,7 +344,7 @@ Var AppStartMenuFolder ; Use show readme button in the finish page as a button create a desktop shortcut !define MUI_FINISHPAGE_SHOWREADME !define MUI_FINISHPAGE_SHOWREADME_TEXT "$(createDesktop)" -!define MUI_FINISHPAGE_SHOWREADME_FUNCTION CreateDesktopShortcut +!define MUI_FINISHPAGE_SHOWREADME_FUNCTION CreateOrUpdateDesktopShortcut ; Show run app after installation. !define MUI_FINISHPAGE_RUN "$INSTDIR\${MAINBINARYNAME}.exe" !define MUI_PAGE_CUSTOMFUNCTION_PRE SkipIfPassive @@ -387,16 +387,19 @@ FunctionEnd Function .onInit ${GetOptions} $CMDLINE "/P" $PassiveMode - IfErrors +2 0 + ${IfNot} ${Errors} StrCpy $PassiveMode 1 + ${EndIf} ${GetOptions} $CMDLINE "/NS" $NoShortcutMode - IfErrors +2 0 + ${IfNot} ${Errors} StrCpy $NoShortcutMode 1 + ${EndIf} ${GetOptions} $CMDLINE "/UPDATE" $UpdateMode - IfErrors +2 0 + ${IfNot} ${Errors} StrCpy $UpdateMode 1 + ${EndIf} !if "${DISPLAYLANGUAGESELECTOR}" == "true" !insertmacro MUI_LANGDLL_DISPLAY @@ -435,7 +438,7 @@ FunctionEnd Section EarlyChecks ; Abort silent installer if downgrades is disabled !if "${ALLOWDOWNGRADES}" == "false" - IfSilent 0 silent_downgrades_done + ${If} ${Silent} ; If downgrading ${If} $R0 = -1 System::Call 'kernel32::AttachConsole(i -1)i.r0' @@ -446,7 +449,7 @@ Section EarlyChecks ${EndIf} Abort ${EndIf} - silent_downgrades_done: + ${EndIf} !endif SectionEnd @@ -577,43 +580,39 @@ Section Install WriteRegDWORD SHCTX "${UNINSTKEY}" "NoRepair" "1" WriteRegDWORD SHCTX "${UNINSTKEY}" "EstimatedSize" "${ESTIMATEDSIZE}" - ; We used to use product name as MAINBINARYNAME - ; migrate old shortcuts to target the new MAINBINARYNAME - Call MigrateProductNameExeShortcuts - ; Create start menu shortcut !insertmacro MUI_STARTMENU_WRITE_BEGIN Application - Call CreateStartMenuShortcut + Call CreateOrUpdateStartMenuShortcut !insertmacro MUI_STARTMENU_WRITE_END ; Create desktop shortcut for silent and passive installers ; because finish page will be skipped - IfSilent create_shortcut 0 - StrCmp $PassiveMode "1" create_shortcut shortcut_done - create_shortcut: - Call CreateDesktopShortcut - shortcut_done: + ${If} $PassiveMode = 1 + ${OrIf} ${Silent} + Call CreateOrUpdateDesktopShortcut + ${EndIf} !ifdef NSIS_HOOK_POSTINSTALL !insertmacro "${NSIS_HOOK_POSTINSTALL}" !endif ; Auto close this page for passive mode - ${IfThen} $PassiveMode = 1 ${|} SetAutoClose true ${|} + ${If} $PassiveMode = 1 + SetAutoClose true + ${EndIf} SectionEnd Function .onInstSuccess ; Check for `/R` flag only in silent and passive installers because ; GUI installer has a toggle for the user to (re)start the app - IfSilent check_r_flag 0 - ${IfThen} $PassiveMode = 1 ${|} Goto check_r_flag ${|} - Goto run_done - check_r_flag: + ${If} $PassiveMode = 1 + ${OrIf} ${Silent} ${GetOptions} $CMDLINE "/R" $R0 - IfErrors run_done 0 + ${IfNot} ${Errors} ${GetOptions} $CMDLINE "/ARGS" $R0 Exec '"$INSTDIR\${MAINBINARYNAME}.exe" $R0' - run_done: + ${EndIf} + ${EndIf} FunctionEnd Function un.onInit @@ -626,8 +625,9 @@ Function un.onInit !insertmacro MUI_UNGETLANGUAGE ${GetOptions} $CMDLINE "/UPDATE" $UpdateMode - IfErrors +2 0 + ${IfNot} ${Errors} StrCpy $UpdateMode 1 + ${EndIf} FunctionEnd Section Uninstall @@ -717,8 +717,9 @@ Section Uninstall ; Auto close if passive mode ${GetOptions} $CMDLINE "/P" $R0 - IfErrors +2 0 + ${IfNot} ${Errors} SetAutoClose true + ${EndIf} SectionEnd Function RestorePreviousInstallLocation @@ -731,7 +732,14 @@ Function SkipIfPassive ${IfThen} $PassiveMode = 1 ${|} Abort ${|} FunctionEnd -Function CreateStartMenuShortcut +Function CreateOrUpdateStartMenuShortcut + ; We used to use product name as MAINBINARYNAME + ; migrate old shortcuts to target the new MAINBINARYNAME + ${If} ${FileExists} "$DESKTOP\${PRODUCTNAME}.lnk" + !insertmacro SetShortcutTarget "$DESKTOP\${PRODUCTNAME}.lnk" "$INSTDIR\${MAINBINARYNAME}.exe" + Return + ${EndIf} + ; Skip creating shortcut if in update mode or no shortcut mode ${If} $UpdateMode = 1 ${OrIf} $NoShortcutMode = 1 @@ -743,7 +751,14 @@ Function CreateStartMenuShortcut !insertmacro SetLnkAppUserModelId "$SMPROGRAMS\$AppStartMenuFolder\${PRODUCTNAME}.lnk" FunctionEnd -Function CreateDesktopShortcut +Function CreateOrUpdateDesktopShortcut + ; We used to use product name as MAINBINARYNAME + ; migrate old shortcuts to target the new MAINBINARYNAME + ${If} ${FileExists} "$SMPROGRAMS\$AppStartMenuFolder\${PRODUCTNAME}.lnk" + !insertmacro SetShortcutTarget "$SMPROGRAMS\$AppStartMenuFolder\${PRODUCTNAME}.lnk" "$INSTDIR\${MAINBINARYNAME}.exe" + Return + ${EndIf} + ; Skip creating shortcut if in update mode or no shortcut mode ${If} $UpdateMode = 1 ${OrIf} $NoShortcutMode = 1 @@ -753,12 +768,3 @@ Function CreateDesktopShortcut CreateShortcut "$DESKTOP\${PRODUCTNAME}.lnk" "$INSTDIR\${MAINBINARYNAME}.exe" !insertmacro SetLnkAppUserModelId "$DESKTOP\${PRODUCTNAME}.lnk" FunctionEnd - -Function MigrateProductNameExeShortcuts - ${If} ${FileExists} "$SMPROGRAMS\$AppStartMenuFolder\${PRODUCTNAME}.lnk" - !insertmacro SetShortcutTarget "$SMPROGRAMS\$AppStartMenuFolder\${PRODUCTNAME}.lnk" "$INSTDIR\${MAINBINARYNAME}.exe" - ${EndIf} - ${If} ${FileExists} "$DESKTOP\${PRODUCTNAME}.lnk" - !insertmacro SetShortcutTarget "$DESKTOP\${PRODUCTNAME}.lnk" "$INSTDIR\${MAINBINARYNAME}.exe" - ${EndIf} -FunctionEnd From 145d436c5953f53ae01fc3db407c970814f13822 Mon Sep 17 00:00:00 2001 From: Tony Date: Fri, 31 May 2024 16:50:16 +0800 Subject: [PATCH 11/11] $PassiveMode for uninstaller --- .../bundler/src/bundle/windows/templates/installer.nsi | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tooling/bundler/src/bundle/windows/templates/installer.nsi b/tooling/bundler/src/bundle/windows/templates/installer.nsi index 1cb66d230374..323dea5f5848 100644 --- a/tooling/bundler/src/bundle/windows/templates/installer.nsi +++ b/tooling/bundler/src/bundle/windows/templates/installer.nsi @@ -624,6 +624,11 @@ Function un.onInit !insertmacro MUI_UNGETLANGUAGE + ${GetOptions} $CMDLINE "/P" $PassiveMode + ${IfNot} ${Errors} + StrCpy $PassiveMode 1 + ${EndIf} + ${GetOptions} $CMDLINE "/UPDATE" $UpdateMode ${IfNot} ${Errors} StrCpy $UpdateMode 1 @@ -716,8 +721,7 @@ Section Uninstall !endif ; Auto close if passive mode - ${GetOptions} $CMDLINE "/P" $R0 - ${IfNot} ${Errors} + ${If} $PassiveMode = 1 SetAutoClose true ${EndIf} SectionEnd