#!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)
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
${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
${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
# .onInit is called
+ Call CheckIfRunning
+
Call RetrieveSMState
Call FindLatex # Search for latex
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