[LyX/master] WinInstaller2: Check if LyX is already running during installation
Juergen Spitzmueller
spitz at lyx.org
Tue Jun 9 07:53:50 UTC 2020
commit b32c9ae8af3a9e5c422214b859e928c84a946dbc
Author: Juergen Spitzmueller <spitz at lyx.org>
Date: Tue Jun 9 10:15:18 2020 +0200
WinInstaller2: Check if LyX is already running during installation
Patch by Eugene
---
development/Win32/packaging/installer/Readme.txt | 3 -
.../Win32/packaging/installer2/src/main.nsh | 47 +++++++++++++++-----
2 files changed, 35 insertions(+), 15 deletions(-)
diff --git a/development/Win32/packaging/installer/Readme.txt b/development/Win32/packaging/installer/Readme.txt
index 598f6a2..0cd2364 100644
--- a/development/Win32/packaging/installer/Readme.txt
+++ b/development/Win32/packaging/installer/Readme.txt
@@ -13,9 +13,6 @@ To build the installer do the following:
extract NSISList-Unicode\NSISList.dll from the second archive to the folder \Plugins\x86-unicode of NSIS's installation folder
- download the plugin ShellLink (https://nsis.sourceforge.io/ShellLink_plug-in)
extract Unicode\Plugins\ShellLink.dll from the archive to the folder \Plugins\x86-unicode of NSIS's installation folder
-- download the plugin nsProcess (https://nsis.sourceforge.io/NsProcess_plugin) with unicode support
- extract Plugin\nsProcessW.dll from the archive to the folder \Plugins\x86-unicode of NSIS's installation folder and rename it to nsProcess.dll
- extract Include\nsProcess.nsh from the archive to the folder \Include of NSIS's installation folder
- Go to the Qt-kit directory, which you have specified as CMAKE_PREFIX_PATH before compiling in CMake Gui, enter the bin folder,
copy these files:
Qt5Concurrent.dll"
diff --git a/development/Win32/packaging/installer2/src/main.nsh b/development/Win32/packaging/installer2/src/main.nsh
index c8933c8..ca3487d 100644
--- a/development/Win32/packaging/installer2/src/main.nsh
+++ b/development/Win32/packaging/installer2/src/main.nsh
@@ -126,7 +126,7 @@
#!include LogicLib.nsh # included in MUI2 # Allows using logic commands (such as ${If}..${Else}..${EndIf})
#!include LangFile.nsh # included in MUI2 # Header file to create language files that can be included with a single command.
- !include x64.nsh # Header file to check if target system is 64 bit or not with ${RunningX64}
+ !include x64.nsh # Header file to check if target system is 64 bit or not with ${RunningX64}, also defines ${DisableX64FSRedirection} and ${EnableX64FSRedirection}
!include NSISList.nsh # Header file to create and work with lists in NSIS (plugin)
!include nsProcess.nsh # Header file to search for a running process (plugin)
@@ -297,13 +297,6 @@ Function .onInit # Callback function, called at the very beginning, when user do
MessageBox MB_OK|MB_ICONSTOP "LyX ${APP_VERSION} requires Windows 7 or newer." /SD IDOK
Quit
${endif}
-
- # Check that LyX is not currently running
- ${nsProcess::FindProcess} "LyX.exe" $R0
- ${if} $R0 == "0"
- MessageBox MB_OK|MB_ICONSTOP "$(UnInstallRunning)" /SD IDOK
- Quit
- ${endif}
Call PrepareShellCTX # MULTIUSER_INIT should search in the right registry view
!insertmacro MULTIUSER_INIT # Verify multiuser privileges
@@ -341,6 +334,23 @@ Function .onInit # Callback function, called at the very beginning, when user do
${Loop}
FunctionEnd
+Function CheckIfRunning # Check that LyX in $INSTDIR is not currently running, called from Function VerifyInstDir and Section -CheckSilent (if silentinstall)
+ ${If} ${RunningX64}
+ ${DisableX64FSRedirection} # We need the following process to be 64 bit on 64 bit system
+ ${EndIf}
+ nsExec::ExecToStack "powershell (Get-Process LyX).Path"
+ Pop $0 # Exit code
+ Pop $0 # Result string
+ ${If} ${RunningX64}
+ ${EnableX64FSRedirection} # Need to be anabled asap or installer might crash
+ ${EndIf}
+ ${StrStr} $0 $0 "$INSTDIR\bin\LyX.exe"
+ ${If} $0 != ""
+ MessageBox MB_OK|MB_ICONSTOP "$(UnInstallRunning)" /SD IDOK
+ Abort # Abort leaving the page (when called from the page callback) / Abort install (when called from the section)
+ ${EndIf}
+FunctionEnd
+
Function VerifyInstDir # Custom Function, called when leaving directory page
# if the $INSTDIR does not contain "LyX" we must add a subfolder to avoid that LyX will e.g.
# be installed directly to "C:\Program Files" - the uninstaller will then delete the whole
@@ -351,6 +361,8 @@ Function VerifyInstDir # Custom Function, called when leaving directory page
${NSD_SetText} $mui.DirectoryPage.Directory $INSTDIR # Refresh Textbox
Abort # Abort leaving the page
${EndIf}
+
+ Call CheckIfRunning
FunctionEnd
Function RetrieveSMState # Custom function, called after the Startmenu page has been created
@@ -490,6 +502,8 @@ Section -CheckSilent # This section checks if it's a silent install and calls ne
# .onInit is called
+ Call CheckIfRunning
+
Call RetrieveSMState
Call FindLatex # Search for latex
@@ -990,11 +1004,20 @@ FunctionEnd
Function un.onInit # Callback function, called when the uninstaller initializes
# Check that LyX is not currently running
- ${nsProcess::FindProcess} "LyX.exe" $R0
- ${If} $R0 == "0"
+ ${If} ${RunningX64}
+ ${DisableX64FSRedirection} # We need the following process to be 64 bit on 64 bit system
+ ${EndIf}
+ nsExec::ExecToStack "powershell (Get-Process LyX).Path"
+ Pop $0 # Exit code
+ Pop $0 # Result string
+ ${If} ${RunningX64}
+ ${EnableX64FSRedirection} # Need to be anabled asap or installer might crash
+ ${EndIf}
+ ${UnStrStr} $0 $0 "$INSTDIR\bin\LyX.exe"
+ ${If} $0 != ""
MessageBox MB_OK|MB_ICONSTOP "$(UnInstallRunning)" /SD IDOK
- Quit
- ${endif}
+ Quit # Quit uninstaller
+ ${EndIf}
Call un.PrepareShellCTX
!insertmacro MULTIUSER_UNINIT
More information about the lyx-cvs
mailing list