diff --git a/ChangeLog.txt b/ChangeLog.txt index 78d48216..8e8ec4fc 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -19,6 +19,11 @@ Broker: Clients: - Fix mosquitto_rr not honouring `-R`. Closes #2893. +Windows: +- Installer will start/stop the mosquitto service when installing and + uninstalling, to prevent problems with not being able to overwrite or remove + mosquitto.exe. + 2.0.17 - 2023-08-22 =================== diff --git a/installer/mosquitto.nsi b/installer/mosquitto.nsi index 1dc55383..40d8e429 100644 --- a/installer/mosquitto.nsi +++ b/installer/mosquitto.nsi @@ -40,7 +40,12 @@ InstallDir "$PROGRAMFILES\mosquitto" Section "Files" SecInstall SectionIn RO + + ExecWait 'sc stop mosquitto' + Sleep 1000 + SetOutPath "$INSTDIR" + File "..\logo\mosquitto.ico" File "..\build\src\Release\mosquitto.exe" File "..\build\apps\mosquitto_passwd\Release\mosquitto_passwd.exe" File "..\build\apps\mosquitto_ctrl\Release\mosquitto_ctrl.exe" @@ -75,6 +80,7 @@ Section "Files" SecInstall WriteUninstaller "$INSTDIR\Uninstall.exe" WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Mosquitto" "DisplayName" "Eclipse Mosquitto MQTT broker" + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Mosquitto" "DisplayIcon" "$INSTDIR\mosquitto.ico" WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Mosquitto" "UninstallString" "$\"$INSTDIR\Uninstall.exe$\"" WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Mosquitto" "QuietUninstallString" "$\"$INSTDIR\Uninstall.exe$\" /S" WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Mosquitto" "HelpLink" "https://mosquitto.org/" @@ -89,10 +95,15 @@ SectionEnd Section "Service" SecService ExecWait '"$INSTDIR\mosquitto.exe" install' + ExecWait 'sc start mosquitto' SectionEnd Section "Uninstall" + ExecWait 'sc stop mosquitto' + Sleep 1000 ExecWait '"$INSTDIR\mosquitto.exe" uninstall' + Sleep 1000 + Delete "$INSTDIR\mosquitto.exe" Delete "$INSTDIR\mosquitto_ctrl.exe" Delete "$INSTDIR\mosquitto_passwd.exe" @@ -114,6 +125,7 @@ Section "Uninstall" Delete "$INSTDIR\libcrypto-1_1.dll" Delete "$INSTDIR\edl-v10" Delete "$INSTDIR\epl-v20" + Delete "$INSTDIR\mosquitto.ico" Delete "$INSTDIR\devel\mosquitto.h" Delete "$INSTDIR\devel\mosquitto.lib" diff --git a/installer/mosquitto64.nsi b/installer/mosquitto64.nsi index 6894c0e5..80d2f5b2 100644 --- a/installer/mosquitto64.nsi +++ b/installer/mosquitto64.nsi @@ -41,7 +41,12 @@ InstallDir "$PROGRAMFILES64\mosquitto" Section "Files" SecInstall SectionIn RO + + ExecWait 'sc stop mosquitto' + Sleep 1000 + SetOutPath "$INSTDIR" + File "..\logo\mosquitto.ico" File "..\build64\src\Release\mosquitto.exe" File "..\build64\apps\mosquitto_ctrl\Release\mosquitto_ctrl.exe" File "..\build64\apps\mosquitto_passwd\Release\mosquitto_passwd.exe" @@ -81,6 +86,7 @@ Section "Files" SecInstall WriteUninstaller "$INSTDIR\Uninstall.exe" WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Mosquitto64" "DisplayName" "Eclipse Mosquitto MQTT broker (64 bit)" + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Mosquitto64" "DisplayIcon" "$INSTDIR\mosquitto.ico" WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Mosquitto64" "UninstallString" "$\"$INSTDIR\Uninstall.exe$\"" WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Mosquitto64" "QuietUninstallString" "$\"$INSTDIR\Uninstall.exe$\" /S" WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Mosquitto64" "HelpLink" "https://mosquitto.org/" @@ -102,10 +108,15 @@ SectionEnd Section "Service" SecService ExecWait '"$INSTDIR\mosquitto.exe" install' + ExecWait 'sc start mosquitto' SectionEnd Section "Uninstall" + ExecWait 'sc stop mosquitto' + Sleep 1000 ExecWait '"$INSTDIR\mosquitto.exe" uninstall' + Sleep 1000 + Delete "$INSTDIR\mosquitto.dll" Delete "$INSTDIR\mosquitto.exe" Delete "$INSTDIR\mosquitto_ctrl.exe" @@ -126,6 +137,7 @@ Section "Uninstall" Delete "$INSTDIR\SECURITY.md" Delete "$INSTDIR\edl-v10" Delete "$INSTDIR\epl-v20" + Delete "$INSTDIR\mosquitto.ico" Delete "$INSTDIR\cjson.dll" Delete "$INSTDIR\libcrypto-3-x64.dll"