diff --git a/docs/sources/set-up/install/windows.md b/docs/sources/set-up/install/windows.md index 7d7be8a6572..a6836f5df2a 100644 --- a/docs/sources/set-up/install/windows.md +++ b/docs/sources/set-up/install/windows.md @@ -73,6 +73,8 @@ To do a silent install of {{< param "PRODUCT_NAME" >}} on Windows, perform the f - `/DISABLEREPORTING=` Disable [data collection][]. Default: `no` - `/DISABLEPROFILING=` Disable profiling endpoint. Default: `no` - `/ENVIRONMENT="KEY=VALUE\0KEY2=VALUE2"` Define environment variables for Windows Service. Default: `` +- `/FORCEREGISTRY=yes` At the start of installation, delete all Alloy registry keys and then run the rest of the install as normal so that install options such as `/STABILITY` and `/DISABLEREPORTING` are written fresh. + By default, the installer preserves existing registry values on upgrade; use this flag to reset them and apply the options passed on the command line, and to remove any old or unused registry keys from previous versions. - `/RUNTIMEPRIORITY="normal|below_normal|above_normal|high|idle|realtime"` Set the runtime priority of the {{< param "PRODUCT_NAME" >}} process. Default: `normal` - `/STABILITY="generally-available|public-preview|experimental"` Set the stability level of {{< param "PRODUCT_NAME" >}}. Default: `generally-available` - `/USERNAME=""` Set the fully qualified user that Windows uses to run the service. Default: `NT AUTHORITY\LocalSystem` diff --git a/packaging/windows/install_script.nsis b/packaging/windows/install_script.nsis index 367f233efa8..d4789e2fff4 100644 --- a/packaging/windows/install_script.nsis +++ b/packaging/windows/install_script.nsis @@ -44,6 +44,7 @@ Var StabilityFlag Var User Var Password Var AuthFlag +Var ForceRegistry # Pages during the installer. Page license @@ -66,10 +67,19 @@ Section "install" ${GetOptions} $PassedInParameters "/CONFIG=" $Config ${GetOptions} $PassedInParameters "/USERNAME=" $User ${GetOptions} $PassedInParameters "/PASSWORD=" $Password + ${GetOptions} $PassedInParameters "/FORCEREGISTRY=" $ForceRegistry # Calls to functions like nsExec::ExecToLog below push the exit code to the # stack, and must be popped after calling. + # When /FORCEREGISTRY=yes, delete all Alloy registry keys at the start so the + # rest of the installation can proceed as normal and write fresh values. This + # also cleans up any old or unused keys from previous versions. + ${If} $ForceRegistry == "yes" + nsExec::ExecToLog 'Reg.exe delete "HKLM\SOFTWARE\GrafanaLabs\Alloy" /reg:64 /f' + Pop $0 + ${EndIf} + # Preemptively stop the existing service if it's running. nsExec::ExecToLog 'sc stop "Alloy"' Pop $0 @@ -174,7 +184,6 @@ Function CreateDataDirectory Return FunctionEnd - # InitializeRegistry initializes the keys in the registry that the service # runner uses. If the registry values already exist, they are not overwritten. Function InitializeRegistry