private void ResetAutoLogon(string domainName, string userName)
        {
            var actualDomainNameForAutoLogon = _registryManager.GetValue(RegistryHive.LocalMachine,
                                                                         RegistryConstants.MachineSettings.SubKeys.AutoLogon,
                                                                         RegistryConstants.MachineSettings.ValueNames.AutoLogonDomainName);

            var actualUserNameForAutoLogon = _registryManager.GetValue(RegistryHive.LocalMachine,
                                                                       RegistryConstants.MachineSettings.SubKeys.AutoLogon,
                                                                       RegistryConstants.MachineSettings.ValueNames.AutoLogonUserName);

            if (string.Equals(actualDomainNameForAutoLogon, domainName, StringComparison.CurrentCultureIgnoreCase) &&
                string.Equals(actualUserNameForAutoLogon, userName, StringComparison.CurrentCultureIgnoreCase))
            {
                _registryManager.SetValue(RegistryHive.LocalMachine, RegistryConstants.MachineSettings.SubKeys.AutoLogon, RegistryConstants.MachineSettings.ValueNames.AutoLogonUserName, "");
                _registryManager.SetValue(RegistryHive.LocalMachine, RegistryConstants.MachineSettings.SubKeys.AutoLogon, RegistryConstants.MachineSettings.ValueNames.AutoLogonDomainName, "");
                _registryManager.SetValue(RegistryHive.LocalMachine, RegistryConstants.MachineSettings.SubKeys.AutoLogon, RegistryConstants.MachineSettings.ValueNames.AutoLogon, "0");
            }
            else
            {
                Trace.Info("AutoLogon user and/or domain name is not same as expected after autologon configuration.");
                Trace.Info($"Actual values: Domain - {actualDomainNameForAutoLogon}, user - {actualUserNameForAutoLogon}");
                Trace.Info($"Expected values: Domain - {domainName}, user - {userName}");
                Trace.Info("Skipping the revert of autologon settings.");
            }
        }
        private void TakeBackupAndSetValue(RegistryHive targetHive, string subKeyName, string name, string value)
        {
            //take backup if it exists
            string origValue = _registryManager.GetValue(targetHive, subKeyName, name);

            if (!string.IsNullOrEmpty(origValue))
            {
                var nameForTheBackupValue = GetBackupValueName(name);
                _registryManager.SetValue(targetHive, subKeyName, nameForTheBackupValue, origValue);
            }

            _registryManager.SetValue(targetHive, subKeyName, name, value);
        }