diff --git a/PowerEditor/installer/nsisInclude/tools.nsh b/PowerEditor/installer/nsisInclude/tools.nsh index 2e00f278..826f981c 100644 --- a/PowerEditor/installer/nsisInclude/tools.nsh +++ b/PowerEditor/installer/nsisInclude/tools.nsh @@ -26,22 +26,28 @@ ; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Function LaunchNpp - ;Exec '"$INSTDIR\notepad++.exe" "$INSTDIR\change.log" ' + ; Open notepad instance with same integrity level as explorer, + ; so that drag n drop continue to function even + ; Once npp is launched, show change.log file (this is to handle issues #2896, #2979, #3014) + ; Caveats: + ; 1. If launching npp takes more time (which is rare), changelog will not be shown + ; 2. If previous npp is configured as "Always in multi-instance mode", then + ; a. Two npp instances will be opened which is not expected + ; b. Second instance may not support drag n drop if current user's integrity level is not as admin + Exec '"$WINDIR\explorer.exe" "$INSTDIR\notepad++.exe"' - ; create shortcut in temp with to launch as argument - CreateShortCut "$TEMP\notepad++.lnk" "$INSTDIR\notepad++.exe" "$INSTDIR\change.log" - - ; Launch Notepad++ with same elevation as explorer - ; It will solve the drag an drop issue if explorer is running with lower privilege - Exec '"$WINDIR\explorer.exe" "$TEMP\notepad++.lnk"' - - ; Caution : Please DONOT delete $TEMP\notepad++.lnk right after Exec command - ; In slower system it may take some time to open N++ while Exec command exist quickly - ; Also putting sleep does not make sense here as - ; - DONOT know how much to wait - ; - Keeps installer UI open wait time period - ; - If wait time is more, installer UI may become irresponsive + ; Max 5 seconds wait here to open change.log + ; If npp is not available even after 5 seconds, exit without showing change.log + ${ForEach} $R1 1 5 + 1 ; Loop to find opened Npp instance + System::Call 'kernel32::OpenMutex(i 0x100000, b 0, t "nppInstance") i .R0' + IntCmp $R0 0 NotYetExecuted + System::Call 'kernel32::CloseHandle(i $R0)' + Exec '"$INSTDIR\notepad++.exe" "$INSTDIR\change.log" ' + ${Break} + NotYetExecuted: + Sleep 1000 + ${Next} FunctionEnd ; Check if Notepad++ is running