diff --git a/src/windows/installer-translations/english.nsi b/src/windows/installer-translations/english.nsi index cfbe4c57e..1cad50928 100644 --- a/src/windows/installer-translations/english.nsi +++ b/src/windows/installer-translations/english.nsi @@ -12,6 +12,8 @@ LangString inst_torrent ${LANG_ENGLISH} "Open .torrent files with qBittorrent" LangString inst_magnet ${LANG_ENGLISH} "Open magnet links with qBittorrent" ;LangString inst_firewall ${LANG_ENGLISH} "Add Windows Firewall rule" LangString inst_firewall ${LANG_ENGLISH} "Add Windows Firewall rule" +;LangString inst_warning ${LANG_ENGLISH} "qBittorrent is running. Please close the application before installing." +LangString inst_warning ${LANG_ENGLISH} "qBittorrent is running. Please close the application before installing." ;------------------------------------ @@ -31,3 +33,5 @@ LangString remove_conf ${LANG_ENGLISH} "Remove configuration files" LangString remove_firewall ${LANG_ENGLISH} "Remove Windows Firewall rule" ;LangString remove_cache ${LANG_ENGLISH} "Remove torrents and cached data" LangString remove_cache ${LANG_ENGLISH} "Remove torrents and cached data" +;LangString uninst_warning ${LANG_ENGLISH} "qBittorrent is running. Please close the application before uninstalling." +LangString uninst_warning ${LANG_ENGLISH} "qBittorrent is running. Please close the application before uninstalling." diff --git a/src/windows/installer.nsi b/src/windows/installer.nsi index 4db6747a8..d812bed89 100644 --- a/src/windows/installer.nsi +++ b/src/windows/installer.nsi @@ -107,7 +107,7 @@ SectionEnd ;-------------------------------- -Function .onInit +Function .onInit ;Search if qBittorrent is already installed. FindFirst $0 $1 "$INSTDIR\uninst.exe" FindClose $0 @@ -128,3 +128,17 @@ Function .onInit !insertmacro MUI_LANGDLL_DISPLAY FunctionEnd + +Function check_instance + + check: + FindProcDLL::FindProc "qbittorrent.exe" + StrCmp $R0 "1" 0 notfound + MessageBox MB_RETRYCANCEL|MB_ICONEXCLAMATION $(inst_warning) IDRETRY check IDCANCEL done + + done: + Abort + + notfound: + +FunctionEnd diff --git a/src/windows/options.nsi b/src/windows/options.nsi index 2a47b4f7a..6a5c3dea5 100644 --- a/src/windows/options.nsi +++ b/src/windows/options.nsi @@ -65,6 +65,7 @@ RequestExecutionLevel admin ;Installer Pages !insertmacro MUI_PAGE_WELCOME !insertmacro MUI_PAGE_LICENSE "license.txt" +!define MUI_PAGE_CUSTOMFUNCTION_LEAVE check_instance !insertmacro MUI_PAGE_COMPONENTS !insertmacro MUI_PAGE_DIRECTORY !insertmacro MUI_PAGE_INSTFILES @@ -73,6 +74,7 @@ RequestExecutionLevel admin ;-------------------------------- ;Uninstaller Pages !insertmacro MUI_UNPAGE_CONFIRM +!define MUI_PAGE_CUSTOMFUNCTION_LEAVE un.check_instance !insertmacro MUI_UNPAGE_COMPONENTS !insertmacro MUI_UNPAGE_INSTFILES diff --git a/src/windows/uninstaller.nsi b/src/windows/uninstaller.nsi index 8f3036929..89e406e3b 100644 --- a/src/windows/uninstaller.nsi +++ b/src/windows/uninstaller.nsi @@ -90,3 +90,17 @@ Function un.onInit !insertmacro MUI_UNGETLANGUAGE FunctionEnd + +Function un.check_instance + + check: + FindProcDLL::FindProc "qbittorrent.exe" + StrCmp $R0 "1" 0 notfound + MessageBox MB_RETRYCANCEL|MB_ICONEXCLAMATION $(uninst_warning) IDRETRY check IDCANCEL done + + done: + Abort + + notfound: + +FunctionEnd