Browse Source

Fix silent installer mode when Notepad++ is running issue

When Notepad++ installer with the '/S' optional param is used while a previously installed Notepad++ instance is running, it does not update the locked main 'notepad++.exe' binary, but the installer still reports success (exit code == 0, regkeys actualized according to the installer version used...).

Moreover - because the installation/upgrade then looks like it is done, some automatic update services like winget cannot be used until a next N++ version is released (winget erroneously reports that the current version is already installed...).

The fix consist to set error code and quit installer, when installer in silent mode, and there's an instance of Notepad++ open.

Fix #10189, fix #10277, fix #22514, fix #14236, fix partially #8514, close #14251
pull/14284/head
xomx 1 year ago committed by Don Ho
parent
commit
5c80be7667
  1. 10
      PowerEditor/installer/nppSetup.nsi

10
PowerEditor/installer/nppSetup.nsi

@ -150,6 +150,16 @@ Function .onInit
;
; --- PATCH END ---
; handle the possible Silent Mode (/S) & already running Notepad++ (without this an incorrect partial installation is possible)
IfSilent 0 notInSilentMode
System::Call 'kernel32::OpenMutex(i 0x100000, b 0, t "nppInstance") i .R0'
IntCmp $R0 0 nppNotRunning
System::Call 'kernel32::CloseHandle(i $R0)' ; a Notepad++ instance is running, tidy-up the opened mutex handle only
SetErrorLevel 5 ; set an exit code > 0 otherwise the installer returns 0 aka SUCCESS ('5' means here the future ERROR_ACCESS_DENIED when trying to overwrite the notepad++.exe file...)
Quit ; silent installation is silent, currently we cannot continue without a user interaction (TODO: a new "/closeRunningNppAutomatically" installer optional param...)
nppNotRunning:
notInSilentMode:
${GetParameters} $R0
${GetOptions} $R0 "/noUpdater" $R1 ;case insensitive
IfErrors withUpdater withoutUpdater

Loading…
Cancel
Save