public void Unconfigure() { if (!_windowsServiceHelper.IsRunningInElevatedMode()) { Trace.Error("Needs Administrator privileges to unconfigure an agent running with AutoLogon capability."); throw new SecurityException(StringUtil.Loc("NeedAdminForAutologonRemoval")); } var autoLogonSettings = _store.GetAutoLogonSettings(); _autoLogonRegManager.ResetRegistrySettings(autoLogonSettings.UserDomainName, autoLogonSettings.UserName); _windowsServiceHelper.ResetAutoLogonPassword(); Trace.Info("Deleting the autologon settings now."); _store.DeleteAutoLogonSettings(); Trace.Info("Successfully deleted the autologon settings."); }
public void Unconfigure() { if (!_windowsServiceHelper.IsRunningInElevatedMode()) { Trace.Error("Needs Administrator privileges to unconfigure an agent running with AutoLogon capability."); throw new SecurityException(StringUtil.Loc("NeedAdminForAutologonRemoval")); } var autoLogonSettings = _store.GetAutoLogonSettings(); _autoLogonRegManager.ResetRegistrySettings(autoLogonSettings.UserDomainName, autoLogonSettings.UserName); _windowsServiceHelper.ResetAutoLogonPassword(); // Delete local group we created during configure. string agentRoot = HostContext.GetDirectory(WellKnownDirectory.Root); string workFolder = HostContext.GetDirectory(WellKnownDirectory.Work); _windowsServiceHelper.RevokeDirectoryPermissionForAccount(new[] { agentRoot, workFolder }); Trace.Info("Deleting the autologon settings now."); _store.DeleteAutoLogonSettings(); Trace.Info("Successfully deleted the autologon settings."); }