When trying to install or upgrade AADConnect I'm getting the error "The Registry Key SetupFiles was not found" and the trace file contains the following error stack:
[12:05:20.808] [ 1] [INFO ] Determining installation action for Azure AD Sync Engine (545334d7-13cd-4bab-8da1-2775fa8cf7c2)
[12:05:20.808] [ 1] [WARN ] An unexpected error occurred while reading the SetupFiles registry key.
Exception Data (Raw): System.ArgumentException: Path cannot be the empty string or all whitespace.
at System.IO.Directory.CreateDirectory(String path)
at System.Management.Automation.Host.PSHostUserInterface.GetTranscriptOptionFromSettings(Dictionary`2 settings, TranscriptionOption currentTranscript)
at System.Management.Automation.Host.PSHostUserInterface.GetSystemTranscriptOption(TranscriptionOption currentTranscript)
at System.Management.Automation.Host.PSHostUserInterface.CheckSystemTranscript()
at System.Management.Automation.Internal.Host.InternalHostUserInterface..ctor(PSHostUserInterface externalUI, InternalHost parentHost)
at System.Management.Automation.Internal.Host.InternalHost..ctor(PSHost externalHost, ExecutionContext executionContext)
at System.Management.Automation.ExecutionContext.InitializeCommon(AutomationEngine engine, PSHost hostInterface)
at System.Management.Automation.AutomationEngine..ctor(PSHost hostInterface, RunspaceConfiguration runspaceConfiguration, InitialSessionState iss)
at System.Management.Automation.Runspaces.LocalRunspace.DoOpenHelper()
at System.Management.Automation.Runspaces.RunspaceBase.CoreOpen(Boolean syncCall)
at System.Management.Automation.PowerShell.Worker.CreateRunspaceIfNeededAndDoWork(Runspace rsToUse, Boolean isSync)
at System.Management.Automation.PowerShell.CoreInvokeHelper[TInput,TOutput](PSDataCollection`1 input, PSDataCollection`1 output, PSInvocationSettings settings)
at System.Management.Automation.PowerShell.CoreInvoke[TInput,TOutput](PSDataCollection`1 input, PSDataCollection`1 output, PSInvocationSettings settings)
at System.Management.Automation.PowerShell.Invoke(IEnumerable input, PSInvocationSettings settings)
at Microsoft.Online.Deployment.PowerShell.LocalPowerShell.Invoke()
at Microsoft.Online.Deployment.PowerShell.PowerShellHelper.InvokeCommand(IPowerShell powerShell, Command command)
at Microsoft.Online.Deployment.PowerShell.PowerShellHelper.GetRegistryValue(IPowerShell powerShell, String keyPath, String valueName, Object& data)
[12:05:20.808] [ 1] [ERROR] Caught an exception while creating the initial page set on the root page.
Exception Data (Raw): System.Exception: The Registry Key SetupFiles was not found.
at Microsoft.Online.Deployment.Types.Providers.EnvironmentProvider.GetSetupFilesPath()
at Microsoft.Online.Deployment.Types.SoftwareComponents.AzureADSyncEngineComponent.InitializeMinimumVersion()
at Microsoft.Online.Deployment.Types.SoftwareComponents.AzureADSyncEngineComponent.CheckInstallationState(IEnumerable`1 installedPackages)
at Microsoft.Online.Deployment.Framework.SoftwareComponents.DependentSoftwareProduct.CheckInstallationState()
at System.Collections.Generic.List`1.ForEach(Action`1 action)
at Microsoft.Online.Deployment.OneADWizard.Runtime.Stages.DetectInstalledComponents.Execute(String& message, GlobalContext globalWizardContext, Boolean& isPasswordSyncSupported)
at Microsoft.Online.Deployment.OneADWizard.UI.WizardPages.RootPageViewModel.GetInitialPagesCore()
at Microsoft.Online.Deployment.OneADWizard.UI.WizardPages.RootPageViewModel.GetInitialPages()
[14:20:23.469] [ 1] [INFO ] Opened log file at path C:\ProgramData\AADConnect\trace-20210611-115424.log