private void Reset(RegistryEntry entry, object value) { if (value is null) { var deleted = entry.TryDelete(); if (!deleted && entry.GetValue() != null) { throw new IOException($"Failed to delete registry key '{entry}'!"); } Logger.Log($"Deleted registry key '{entry}'."); } else { entry.SetValue(value); Logger.Log($"Set registry key '{entry}' to '{value}'."); } }
private static void Reset(RegistryEntry entry, object value) { try { if (entry.IsUserSpecific() && !entry.IsHiveAvailable()) { OutputAndLog($"User hive is not available, cannot reset registry key '{entry}'!"); } else { entry.SetValue(value); Console.ForegroundColor = ConsoleColor.Green; OutputAndLog($@"Successfully set '{entry}' to '{value}'"); } } catch (Exception e) { Console.ForegroundColor = ConsoleColor.Red; OutputAndLog($@"Failed to set '{entry}' to '{value}'"); Log(e); } }