diff --git a/app/win/download-nsis-plugins b/app/win/download-nsis-plugins index f02c60e77b..6e067b267d 100755 --- a/app/win/download-nsis-plugins +++ b/app/win/download-nsis-plugins @@ -46,6 +46,11 @@ for plugin in $plugins; do curl https://hg.mozilla.org/mozilla-central/raw-file/052d53200cf8/other-licenses/nsis/Plugins/$plugin.dll > $plugin.dll done +curl https://nsis.sourceforge.io/mediawiki/images/1/18/NsProcess.zip > NsProcess.zip +7z e NsProcess.zip "Plugin/nsProcessW.dll" +mv nsProcessW.dll nsProcess.dll +rm NsProcess.zip + echo echo echo "Files downloaded to ./Plugins -- move to ${NSIS_DIR}Plugins" diff --git a/app/win/installer/installer.nsi b/app/win/installer/installer.nsi index 2aa6115d36..5e1154c39c 100755 --- a/app/win/installer/installer.nsi +++ b/app/win/installer/installer.nsi @@ -59,6 +59,7 @@ Var InstallType !insertmacro WordFind !insertmacro WordReplace +!include nsProcess.nsh ; The following includes are custom. !include branding.nsi !include defines.nsi @@ -962,6 +963,21 @@ Function .onInit ${EndIf} !endif + # Check if Zotero is running. If it is, prompt the user to close Zotero and exit. + # For silent installs, kill Zotero and if successful, continue with the install. + ${nsProcess::FindProcess} ${FileMainEXE} $R0 + ${If} $R0 = 0 + IfSilent +3 + MessageBox MB_OK|MB_ICONSTOP "Zotero is already running. Please close Zotero before running the installer." + Quit + ${nsProcess::KillProcess} ${FileMainEXE} $R0 + Sleep 500 + ${nsProcess::FindProcess} ${FileMainEXE} $R0 + ${If} $R0 = 0 + Quit + ${EndIf} + ${EndIf} + StrCpy $R1 "Zotero Standalone" StrCpy $R2 "An older version of Zotero is installed. If you continue, the existing version will be removed.$\n$\nYour Zotero data will not be affected." Call UninstallOld diff --git a/app/win/installer/nsProcess.nsh b/app/win/installer/nsProcess.nsh new file mode 100644 index 0000000000..279f581147 --- /dev/null +++ b/app/win/installer/nsProcess.nsh @@ -0,0 +1,28 @@ +!define nsProcess::FindProcess `!insertmacro nsProcess::FindProcess` + +!macro nsProcess::FindProcess _FILE _ERR + nsProcess::_FindProcess /NOUNLOAD `${_FILE}` + Pop ${_ERR} +!macroend + + +!define nsProcess::KillProcess `!insertmacro nsProcess::KillProcess` + +!macro nsProcess::KillProcess _FILE _ERR + nsProcess::_KillProcess /NOUNLOAD `${_FILE}` + Pop ${_ERR} +!macroend + +!define nsProcess::CloseProcess `!insertmacro nsProcess::CloseProcess` + +!macro nsProcess::CloseProcess _FILE _ERR + nsProcess::_CloseProcess /NOUNLOAD `${_FILE}` + Pop ${_ERR} +!macroend + + +!define nsProcess::Unload `!insertmacro nsProcess::Unload` + +!macro nsProcess::Unload + nsProcess::_Unload +!macroend