@@ -51,6 +51,10 @@ ${StrLoc}
51
51
!define UNINSTALLERSIGNCOMMAND " {{uninstaller_sign_cmd}}"
52
52
!define ESTIMATEDSIZE " {{estimated_size}}"
53
53
54
+ Var PassiveMode
55
+ Var UpdateMode
56
+ Var NoShortcutMode
57
+
54
58
Name " ${PRODUCTNAME}"
55
59
BrandingText " ${COPYRIGHT}"
56
60
OutFile " ${OUTFILE}"
@@ -194,21 +198,21 @@ Function PageReinstall
194
198
nsis_tauri_utils::SemverCompare " ${VERSION}" $R0
195
199
Pop $R0
196
200
; Reinstalling the same version
197
- ${If} $R0 == 0
201
+ ${If} $R0 = 0
198
202
StrCpy $R1 " $(alreadyInstalledLong)"
199
203
StrCpy $R2 " $(addOrReinstall)"
200
204
StrCpy $R3 " $(uninstallApp)"
201
205
!insertmacro MUI_HEADER_TEXT " $(alreadyInstalled)" " $(chooseMaintenanceOption)"
202
206
StrCpy $R5 " 2"
203
207
; Upgrading
204
- ${ElseIf} $R0 == 1
208
+ ${ElseIf} $R0 = 1
205
209
StrCpy $R1 " $(olderOrUnknownVersionInstalled)"
206
210
StrCpy $R2 " $(uninstallBeforeInstalling)"
207
211
StrCpy $R3 " $(dontUninstall)"
208
212
!insertmacro MUI_HEADER_TEXT " $(alreadyInstalled)" " $(choowHowToInstall)"
209
213
StrCpy $R5 " 1"
210
214
; Downgrading
211
- ${ElseIf} $R0 == -1
215
+ ${ElseIf} $R0 = -1
212
216
StrCpy $R1 " $(newerVersionInstalled)"
213
217
StrCpy $R2 " $(uninstallBeforeInstalling)"
214
218
!if " ${ALLOWDOWNGRADES}" == " true"
@@ -232,7 +236,7 @@ Function PageReinstall
232
236
233
237
nsDialogs::Create 1018
234
238
Pop $R4
235
- ${IfThen} $(^RTL) == 1 ${|} nsDialogs::SetRTL $(^RTL) ${|}
239
+ ${IfThen} $(^RTL) = 1 ${|} nsDialogs::SetRTL $(^RTL) ${|}
236
240
237
241
${NSD_CreateLabel} 0 0 100 % 24u $R1
238
242
Pop $R1
@@ -245,14 +249,14 @@ Function PageReinstall
245
249
Pop $R3
246
250
; Disable this radio button if downgrading and downgrades are disabled
247
251
!if " ${ALLOWDOWNGRADES}" == " false"
248
- ${IfThen} $R0 == -1 ${|} EnableWindow $R3 0 ${|}
252
+ ${IfThen} $R0 = -1 ${|} EnableWindow $R3 0 ${|}
249
253
!endif
250
254
${NSD_OnClick} $R3 PageReinstallUpdateSelection
251
255
252
256
; Check the first radio button if this the first time
253
257
; we enter this page or if the second button wasn't
254
258
; selected the last time we were on this page
255
- ${If} $ReinstallPageCheck != 2
259
+ ${If} $ReinstallPageCheck <> 2
256
260
SendMessage $R2 ${BM_SETCHECK} ${BST_CHECKED} 0
257
261
${Else}
258
262
SendMessage $R3 ${BM_SETCHECK} ${BST_CHECKED} 0
@@ -291,7 +295,11 @@ Function PageLeaveReinstall
291
295
${Else}
292
296
ReadRegStr $4 SHCTX " ${MANUPRODUCTKEY}" " "
293
297
ReadRegStr $R1 SHCTX " ${UNINSTKEY}" " UninstallString"
294
- ExecWait ' $R1 /P _?=$4' $0
298
+ ${If} $UpdateMode = 1
299
+ ExecWait ' $R1 /UPDATE /P _?=$4' $0
300
+ ${Else}
301
+ ExecWait ' $R1 /P _?=$4' $0
302
+ ${EndIf}
295
303
${EndIf}
296
304
297
305
BringToFront
@@ -339,7 +347,7 @@ Var AppStartMenuFolder
339
347
!define MUI_FINISHPAGE_SHOWREADME_FUNCTION CreateDesktopShortcut
340
348
; Show run app after installation.
341
349
!define MUI_FINISHPAGE_RUN " $INSTDIR\${MAINBINARYNAME}.exe"
342
- !define MUI_PAGE_CUSTOMFUNCTION_PRE SkipIfPassive
350
+ !define MUI_PAGE_CUSTOMFUNCTION_PRE SkipIfPassiveButUpdateShortcutIfUpdate
343
351
!insertmacro MUI_PAGE_FINISH
344
352
345
353
; Uninstaller Pages
@@ -350,7 +358,7 @@ Var DeleteAppDataCheckboxState
350
358
!define MUI_PAGE_CUSTOMFUNCTION_SHOW un.ConfirmShow
351
359
Function un.ConfirmShow ; Add add a `Delete app data` check box
352
360
FindWindow $1 " #32770" " " $HWNDPARENT ; Find inner dialog
353
- ${If} $(^RTL) == 1
361
+ ${If} $(^RTL) = 1
354
362
System::Call ' USER32::CreateWindowEx(i${__NSD_CheckBox_EXSTYLE}|${WS_EX_LAYOUTRTL},t"${__NSD_CheckBox_CLASS}",t "$(deleteAppData)",i${__NSD_CheckBox_STYLE},i 50,i 100,i 400, i 25,i$1,i0,i0,i0)i.s'
355
363
${Else}
356
364
System::Call ' USER32::CreateWindowEx(i${__NSD_CheckBox_EXSTYLE},t"${__NSD_CheckBox_CLASS}",t "$(deleteAppData)",i${__NSD_CheckBox_STYLE},i 0,i 100,i 400, i 25,i$1,i0,i0,i0)i.s'
@@ -377,13 +385,15 @@ FunctionEnd
377
385
!include " {{this}}"
378
386
{{/each}}
379
387
380
- Var PassiveMode
381
- Var UpdateMode
382
388
Function .onInit
383
389
${GetOptions} $CMDLINE " /P" $PassiveMode
384
390
IfErrors +2 0
385
391
StrCpy $PassiveMode 1
386
392
393
+ ${GetOptions} $CMDLINE " /NS" $NoShortcutMode
394
+ IfErrors +2 0
395
+ StrCpy $NoShortcutMode 1
396
+
387
397
${GetOptions} $CMDLINE " /UPDATE" $UpdateMode
388
398
IfErrors +2 0
389
399
StrCpy $UpdateMode 1
@@ -427,9 +437,9 @@ Section EarlyChecks
427
437
!if " ${ALLOWDOWNGRADES}" == " false"
428
438
IfSilent 0 silent_downgrades_done
429
439
; If downgrading
430
- ${If} $R0 == -1
440
+ ${If} $R0 = -1
431
441
System::Call ' kernel32::AttachConsole(i -1)i.r0'
432
- ${If} $0 != 0
442
+ ${If} $0 <> 0
433
443
System::Call ' kernel32::GetStdHandle(i -11)i.r0'
434
444
System::call ' kernel32::SetConsoleTextAttribute(i r0, i 0x0004)' ; set red color
435
445
FileWrite $0 " $(silentDowngrades)"
@@ -462,7 +472,7 @@ Section WebView2
462
472
DetailPrint " $(webview2Downloading)"
463
473
NSISdl::download " https://go.microsoft.com/fwlink/p/?LinkId=2124703" " $TEMP\MicrosoftEdgeWebview2Setup.exe"
464
474
Pop $0
465
- ${If} $0 == 0
475
+ ${If} $0 = 0
466
476
DetailPrint " $(webview2DownloadSuccess)"
467
477
${Else}
468
478
DetailPrint " $(webview2DownloadError)"
@@ -494,7 +504,7 @@ Section WebView2
494
504
DetailPrint " $(installingWebview2)"
495
505
; $6 holds the path to the webview2 installer
496
506
ExecWait " $6 ${WEBVIEW2INSTALLERARGS} /install" $1
497
- ${If} $1 == 0
507
+ ${If} $1 = 0
498
508
DetailPrint " $(webview2InstallSuccess)"
499
509
${Else}
500
510
DetailPrint " $(webview2InstallError)"
@@ -567,40 +577,32 @@ Section Install
567
577
WriteRegDWORD SHCTX " ${UNINSTKEY}" " NoRepair" " 1"
568
578
WriteRegDWORD SHCTX " ${UNINSTKEY}" " EstimatedSize" " ${ESTIMATEDSIZE}"
569
579
570
- ; Create start menu shortcut (GUI)
580
+ ; Create start menu shortcut
571
581
!insertmacro MUI_STARTMENU_WRITE_BEGIN Application
572
582
Call CreateStartMenuShortcut
573
583
!insertmacro MUI_STARTMENU_WRITE_END
574
584
575
- ; Create shortcuts for silent and passive installers, which
576
- ; can be disabled by passing `/NS` or `/UPDATE` flag.
577
- ;
578
- ; GUI installer has buttons for users to control creating them.
579
- IfSilent check_ns_flag 0
580
- ${IfThen} $PassiveMode == 1 ${|} Goto check_ns_flag ${|}
581
- Goto shortcuts_done
582
- check_ns_flag:
583
- ${GetOptions} $CMDLINE " /NS" $R0
584
- IfErrors 0 shortcuts_done
585
- ${If} $UpdateMode <> 1
586
- Call CreateDesktopShortcut
587
- Call CreateStartMenuShortcut
588
- ${EndIf}
589
- shortcuts_done:
585
+ ; Create desktop shortcut for silent and passive installers
586
+ ; because finish page will be skipped
587
+ IfSilent create_shortcut 0
588
+ StrCmp $PassiveMode " 1" create_shortcut shortcut_done
589
+ create_shortcut:
590
+ Call CreateDesktopShortcut
591
+ shortcut_done:
590
592
591
593
!ifdef NSIS_HOOK_POSTINSTALL
592
594
!insertmacro " ${NSIS_HOOK_POSTINSTALL}"
593
595
!endif
594
596
595
597
; Auto close this page for passive mode
596
- ${IfThen} $PassiveMode == 1 ${|} SetAutoClose true ${|}
598
+ ${IfThen} $PassiveMode = 1 ${|} SetAutoClose true ${|}
597
599
SectionEnd
598
600
599
601
Function .onInstSuccess
600
602
; Check for `/R` flag only in silent and passive installers because
601
603
; GUI installer has a toggle for the user to (re)start the app
602
604
IfSilent check_r_flag 0
603
- ${IfThen} $PassiveMode == 1 ${|} Goto check_r_flag ${|}
605
+ ${IfThen} $PassiveMode = 1 ${|} Goto check_r_flag ${|}
604
606
Goto run_done
605
607
check_r_flag:
606
608
${GetOptions} $CMDLINE " /R" $R0
@@ -618,12 +620,13 @@ Function un.onInit
618
620
!endif
619
621
620
622
!insertmacro MUI_UNGETLANGUAGE
621
- FunctionEnd
622
623
623
- Section Uninstall
624
624
${GetOptions} $CMDLINE " /UPDATE" $UpdateMode
625
625
IfErrors +2 0
626
626
StrCpy $UpdateMode 1
627
+ FunctionEnd
628
+
629
+ Section Uninstall
627
630
628
631
!insertmacro CheckIfAppIsRunning
629
632
@@ -675,13 +678,13 @@ Section Uninstall
675
678
676
679
; Remove start menu shortcut
677
680
!insertmacro MUI_STARTMENU_GETFOLDER Application $AppStartMenuFolder
678
- !insertmacro UnpinShortcut " $SMPROGRAMS\$AppStartMenuFolder\${MAINBINARYNAME }.lnk"
679
- Delete " $SMPROGRAMS\$AppStartMenuFolder\${MAINBINARYNAME }.lnk"
681
+ !insertmacro UnpinShortcut " $SMPROGRAMS\$AppStartMenuFolder\${PRODUCTNAME }.lnk"
682
+ Delete " $SMPROGRAMS\$AppStartMenuFolder\${PRODUCTNAME }.lnk"
680
683
RMDir " $SMPROGRAMS\$AppStartMenuFolder"
681
684
682
685
; Remove desktop shortcuts
683
- !insertmacro UnpinShortcut " $DESKTOP\${MAINBINARYNAME }.lnk"
684
- Delete " $DESKTOP\${MAINBINARYNAME }.lnk"
686
+ !insertmacro UnpinShortcut " $DESKTOP\${PRODUCTNAME }.lnk"
687
+ Delete " $DESKTOP\${PRODUCTNAME }.lnk"
685
688
${EndIf}
686
689
687
690
; Remove registry information for add/remove programs
@@ -721,16 +724,46 @@ Function RestorePreviousInstallLocation
721
724
FunctionEnd
722
725
723
726
Function SkipIfPassive
724
- ${IfThen} $PassiveMode == 1 ${|} Abort ${|}
727
+ ${IfThen} $PassiveMode = 1 ${|} Abort ${|}
728
+ FunctionEnd
729
+
730
+ Function SkipIfPassiveButUpdateShortcutIfUpdate
731
+ ${If} $PassiveMode = 1
732
+ Call CreateDesktopShortcut
733
+ Abort
734
+ ${EndIf}
725
735
FunctionEnd
726
736
727
737
Function CreateDesktopShortcut
728
- CreateShortcut " $DESKTOP\${MAINBINARYNAME}.lnk" " $INSTDIR\${MAINBINARYNAME}.exe"
729
- !insertmacro SetLnkAppUserModelId " $DESKTOP\${MAINBINARYNAME}.lnk"
738
+ ; Skip creating shortcut if in update mode
739
+ ; and shortcuts doesn't exist, which means user deleted it
740
+ ; so we respect that.
741
+ ${If} $UpdateMode = 1
742
+ IfFileExists " $DESKTOP\${PRODUCTNAME}.lnk" +2 0
743
+ Return
744
+ ${EndIf}
745
+
746
+ ${If} $NoShortcutMode = 1
747
+ Return
748
+ ${EndIf}
749
+
750
+ CreateShortcut " $DESKTOP\${PRODUCTNAME}.lnk" " $INSTDIR\${MAINBINARYNAME}.exe"
751
+ !insertmacro SetLnkAppUserModelId " $DESKTOP\${PRODUCTNAME}.lnk"
730
752
FunctionEnd
731
753
732
754
Function CreateStartMenuShortcut
755
+ ; Skip creating shortcut if in update mode.
756
+ ; See `CreateDesktopShortcut` above.
757
+ ${If} $UpdateMode = 1
758
+ IfFileExists " $SMPROGRAMS\$AppStartMenuFolder\${PRODUCTNAME}.lnk" +2 0
759
+ Return
760
+ ${EndIf}
761
+
762
+ ${If} $NoShortcutMode = 1
763
+ Return
764
+ ${EndIf}
765
+
733
766
CreateDirectory " $SMPROGRAMS\$AppStartMenuFolder"
734
- CreateShortcut " $SMPROGRAMS\$AppStartMenuFolder\${MAINBINARYNAME }.lnk" " $INSTDIR\${MAINBINARYNAME}.exe"
735
- !insertmacro SetLnkAppUserModelId " $SMPROGRAMS\$AppStartMenuFolder\${MAINBINARYNAME }.lnk"
767
+ CreateShortcut " $SMPROGRAMS\$AppStartMenuFolder\${PRODUCTNAME }.lnk" " $INSTDIR\${MAINBINARYNAME}.exe"
768
+ !insertmacro SetLnkAppUserModelId " $SMPROGRAMS\$AppStartMenuFolder\${PRODUCTNAME }.lnk"
736
769
FunctionEnd
0 commit comments