diff --git a/DisableNvidiaTelemetry/Controller/NvidiaController.cs b/DisableNvidiaTelemetry/Controller/NvidiaController.cs index 68c60ab..9d00642 100644 --- a/DisableNvidiaTelemetry/Controller/NvidiaController.cs +++ b/DisableNvidiaTelemetry/Controller/NvidiaController.cs @@ -120,7 +120,10 @@ public static IEnumerable> Enumerat error = ex; } - yield return new NvidiaControllerResult(telemetryRegistryKey, error) {Name = key.Name}; + if (key.exists()) + yield return new NvidiaControllerResult(telemetryRegistryKey, error) { Name = key.Name }; + else + yield return new NvidiaControllerResult(null, new RegistryKeyNotFoundException($"Failed to find registry key: {key.Name}")); } } diff --git a/DisableNvidiaTelemetry/Model/TaskNotFoundException.cs b/DisableNvidiaTelemetry/Model/TaskNotFoundException.cs index 8abebe1..1dec875 100644 --- a/DisableNvidiaTelemetry/Model/TaskNotFoundException.cs +++ b/DisableNvidiaTelemetry/Model/TaskNotFoundException.cs @@ -3,7 +3,7 @@ namespace DisableNvidiaTelemetry.Model { /// - /// Represents an exception where a secheduled task could not be found. + /// Represents an exception where a scheduled task could not be found. /// public class TaskNotFoundException : Exception { diff --git a/DisableNvidiaTelemetry/Model/TelemetryRegistryKey.cs b/DisableNvidiaTelemetry/Model/TelemetryRegistryKey.cs index 577c9ee..4598906 100644 --- a/DisableNvidiaTelemetry/Model/TelemetryRegistryKey.cs +++ b/DisableNvidiaTelemetry/Model/TelemetryRegistryKey.cs @@ -127,6 +127,27 @@ public Replacement(Regex regex, string replacment) public string Replacment { get; } } + /// Check to see if the value exists. + /// True if it exists, false if not. + public bool exists() + { + var subKey = SubKey; + + try + { + if (_useRegex) + ValueExpressions.Select(vd => vd.Value.Match.IsMatch(subKey.GetValue(vd.Key).ToString())).FirstOrDefault(); + else + ValueStrings.Any(vd => subKey.GetValue(vd.Key).ToString() == vd.Value.Enabled); + } + catch (System.NullReferenceException) + { + return false; + } + + return true; + } + #region Implementation of ITelemetry public bool IsActive()