public static void DeleteConfiguredVersion(string roleName) { string name = "SOFTWARE\\Microsoft\\ExchangeServer\\v15\\" + RolesUtility.GetRoleKeyByName(roleName, false); RegistryKey registryKey = Registry.LocalMachine.OpenSubKey(name, true); registryKey.DeleteValue("ConfiguredVersion", false); registryKey.DeleteValue("PostSetupVersion", false); registryKey.Close(); try { Registry.LocalMachine.DeleteSubKeyTree("SOFTWARE\\Wow6432Node\\Microsoft\\ExchangeServer\\v15\\" + RolesUtility.GetRoleKeyByName(roleName, false)); } catch (ArgumentException) { } }
public static void GetConfiguringStatus(ref ConfigurationStatus status) { string name = "SOFTWARE\\Microsoft\\ExchangeServer\\v15\\" + RolesUtility.GetRoleKeyByName(status.Role, false); using (RegistryKey registryKey = Registry.LocalMachine.OpenSubKey(name)) { if (registryKey != null) { InstallationModes action = InstallationModes.Unknown; string text = (string)registryKey.GetValue("Action", null); if (text != null) { action = (InstallationModes)Enum.Parse(typeof(InstallationModes), text); } status.Action = action; object value = registryKey.GetValue("Watermark", null); status.Watermark = ((value != null) ? value.ToString() : null); } } }
public static void ClearConfiguringStatus(ConfigurationStatus status) { string name = "SOFTWARE\\Microsoft\\ExchangeServer\\v15\\" + RolesUtility.GetRoleKeyByName(status.Role, false); RegistryKey registryKey = Registry.LocalMachine.OpenSubKey(name, true); if (registryKey != null) { registryKey.DeleteValue("Action", false); registryKey.DeleteValue("Watermark", false); if (registryKey.SubKeyCount == 0 && registryKey.ValueCount == 0) { registryKey.Close(); string name2 = "SOFTWARE\\Microsoft\\ExchangeServer\\v15\\"; RegistryKey registryKey2 = Registry.LocalMachine.OpenSubKey(name2, true); registryKey2.DeleteSubKey(RolesUtility.GetRoleKeyByName(status.Role, false), false); registryKey2.Close(); return; } registryKey.Close(); } }
public static void SetConfiguringStatus(ConfigurationStatus status) { string keyName = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\ExchangeServer\\v15\\" + RolesUtility.GetRoleKeyByName(status.Role, false); Registry.SetValue(keyName, "Action", status.Action); Registry.SetValue(keyName, "Watermark", status.Watermark); }
public static Version GetUnpackedDatacenterVersion(string roleName) { Version result = null; string keyName = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\ExchangeServer\\v15\\" + RolesUtility.GetRoleKeyByName(roleName, false); string text = (string)Registry.GetValue(keyName, "UnpackedDatacenterVersion", null); if (text != null) { result = new Version(text); } return(result); }
public static void SetConfiguredVersion(string roleName, Version configuredVersion) { string keyName = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\ExchangeServer\\v15\\" + RolesUtility.GetRoleKeyByName(roleName, false); string text = (string)Registry.GetValue(keyName, "ConfiguredVersion", "<unset>"); TaskLogger.Trace("Updating configured version from {0} to {1}", new object[] { text, configuredVersion }); Registry.SetValue(keyName, "ConfiguredVersion", configuredVersion.ToString()); if (RolesUtility.GetPostSetupVersion(roleName) == null) { RolesUtility.SetPostSetupVersion(roleName, new Version("0.0.0.0")); } using (RegistryKey registryKey = Registry.LocalMachine.CreateSubKey("SOFTWARE\\Wow6432Node\\Microsoft\\ExchangeServer\\v15\\" + RolesUtility.GetRoleKeyByName(roleName, false))) { registryKey.SetValue("ConfiguredVersion", configuredVersion.ToString()); } }
public static Version GetConfiguredVersion(string roleName) { Version result = null; string keyName = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\ExchangeServer\\v15\\" + RolesUtility.GetRoleKeyByName(roleName, false); string text = (string)Registry.GetValue(keyName, "ConfiguredVersion", null); if (text == null) { keyName = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\ExchangeServer\\v15\\" + RolesUtility.GetRoleKeyByName(roleName, true); text = (string)Registry.GetValue(keyName, "ConfiguredVersion", null); } if (text != null) { result = new Version(text); } else if (roleName == "AdminToolsRole") { Version unpackedVersion = RolesUtility.GetUnpackedVersion(roleName); if (unpackedVersion != null && unpackedVersion < AdminToolsRole.FirstConfiguredVersion) { result = unpackedVersion; } } return(result); }
public static void SetPostSetupVersion(string roleName, Version version) { string keyName = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\ExchangeServer\\v15\\" + RolesUtility.GetRoleKeyByName(roleName, false); string text = (string)Registry.GetValue(keyName, "PostSetupVersion", "<unset>"); TaskLogger.Trace("Updating postsetup version from {0} to {1}", new object[] { text, version }); Registry.SetValue(keyName, "PostSetupVersion", (version == null) ? "" : version.ToString()); }