From 817be06b4a2261275acab8ed6096968bad6b0f8a Mon Sep 17 00:00:00 2001 From: Paschalis Tsilias Date: Wed, 24 Apr 2024 18:23:56 +0300 Subject: [PATCH] packaging: properly unregister Grafana Agent when uninstalling on Windows (#166) (#6867) grafana/agent#6550 fixed an issue where the service settings were not being removed properly, but inadvertedly broke the process of removing the application from the Add/Remove programs list. Grafana AGent is registered as a program to the 32-bit registry, and so it must be removed from the 32-bit registry and not the 64-bit registry. Co-authored-by: Robert Fratto --- CHANGELOG.md | 3 +++ packaging/grafana-agent-flow/windows/install_script.nsis | 7 ++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1ef9e663f508..d3021ebe446b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -84,6 +84,9 @@ Main (unreleased) - Fixed an issue where creating a `prometheus.exporter.postgres` component with multiple `data_source_names` would result in an error. (@thampiotr) +- Fix an issue on Windows where uninstalling Alloy did not remove it from the + Add/Remove programs list. (@rfratto) + ### Other changes - Clustering for Grafana Agent in Flow mode has graduated from beta to stable. diff --git a/packaging/grafana-agent-flow/windows/install_script.nsis b/packaging/grafana-agent-flow/windows/install_script.nsis index dfb8ae95b3c7..0d06eae01d76 100644 --- a/packaging/grafana-agent-flow/windows/install_script.nsis +++ b/packaging/grafana-agent-flow/windows/install_script.nsis @@ -218,9 +218,10 @@ Section "uninstall" RMDir /r "$INSTDIR" # Install directory. RMDir /r "$APPDATA\${APPNAME}" # Application data. - # Remove service and uninstaller information from the registry. + # Remove service and uninstaller information from the registry. Note that the + # service settings are stored in the 64-bit registry (so we use /reg:64), + # while the uninstaller information is stored in the 32-bit registry. nsExec::ExecToLog 'Reg.exe delete "HKLM\SOFTWARE\Grafana\Grafana Agent Flow" /reg:64 /f' Pop $0 - nsExec::ExecToLog 'Reg.exe delete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" /reg:64 /f' - Pop $0 + DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" SectionEnd