private void RefreshTelemetryServices(bool logging) { var services = new List <TelemetryService>(); foreach (var result in NvidiaController.EnumerateTelemetryServices()) { if (logging) { Logging.GetFileLogger().Log(Level.Info, result.Error != null ? $"{Properties.Resources.Failed_to_find_service}: {result.Name}" : $"{Properties.Resources.Found_service}: {result.Item.Service.DisplayName} ({result.Item.Service.ServiceName})"); } if (result.Error == null) { var service = result.Item; var running = service.Service.Status == ServiceControllerStatus.Running; var startupMode = ServiceHelper.GetServiceStartMode(service.Service); var startupModeString = ""; switch (startupMode) { case ServiceStartMode.Manual: startupModeString = Properties.Resources.Manual; break; case ServiceStartMode.Automatic: startupModeString = Properties.Resources.Automatic; break; case ServiceStartMode.Disabled: startupModeString = Properties.Resources.Disabled; break; } if (logging) { Logging.GetFileLogger().Log(Level.Info, running ? $"{Properties.Resources.Service_is}: {Properties.Resources.Enabled}" : $"{Properties.Resources.Service_is}: {Properties.Resources.Disabled}"); Logging.GetFileLogger().Log(Level.Info, $"{Properties.Resources.Service_startup_mode}: {startupModeString}"); } tcServices.AddTelemetryItem(service, $"{Properties.Resources.Service}: {service.Service.DisplayName} ({service.Service.ServiceName})"); services.Add(service); } } _telemetryServices = services; }
private static void SilentlyDisableTelemetry() { Logging.GetFileLogger().Log(Level.Info, "Silently disabling telemetry services."); var services = NvidiaController.GetTelemetryServices(true); NvidiaController.DisableTelemetryServices(services.Select(s => s.Service).ToList(), true, true); Logging.GetFileLogger().Log(Level.Info, "Silently disabling telemetry tasks."); var tasks = NvidiaController.GetTelemetryTasks(true); NvidiaController.DisableTelemetryTasks(tasks.Select(t => t.Task).ToList(), true, true); }
private void RefreshTelemetryServices(bool logging) { var services = new List <ServiceController>(); var serviceQueries = NvidiaController.GetTelemetryServices(); if (serviceQueries.Count > 0) { foreach (var query in serviceQueries) { var serviceFound = false; var running = false; try { running = query.Result.Status == ServiceControllerStatus.Running; serviceFound = true; } catch { if (logging) { AppendLog($"Failed to find service: {query.Query}"); } } if (serviceFound) { if (logging) { AppendLog($"Found Service: {query.Result.DisplayName} ({query.Result.ServiceName})"); AppendLog($"Service is: {(running ? "Enabled" : "Disabled")}"); } if (!running) { _servicesControl.DisabledCount++; } _servicesControl.AddSubAction($"Service: {query.Result.DisplayName} ({query.Result.ServiceName})", running); services.Add(query.Result); } } } _servicesControl.Enabled = !_servicesControl.IsEmpty; _telemetryServices = services; }
private void tcRegistry_DefaultClicked(object sender, EventArgs e) { tcRegistry.Reset(); foreach (var item in _telemetryKeys) { var result = NvidiaController.EnableTelemetryRegistryItem(item); Logging.GetFileLogger().Log(Level.Info, result.Error != null ? $"{Properties.Resources.Failed_to_enable_registry_item}: {result.Item.Name}" : $"{Properties.Resources.Registry_item_enabled}: {result.Item.Name}"); } RefreshTelemetryRegistry(false); }
private void RefreshTelemetryRegistry(bool logging) { var keys = new List <TelemetryRegistryKey>(); foreach (var result in NvidiaController.EnumerateTelemetryRegistryItems()) { if (logging) { Logging.GetFileLogger().Log(Level.Info, result.Error != null ? $"{Properties.Resources.Failed_to_find_registry_item}: {result.Name}" : $"{Properties.Resources.Found_registry_item}: {result.Item.Name}"); } if (result.Error == null) { if (logging) { Logging.GetFileLogger().Log(Level.Info, $"{Properties.Resources.Registry_item_is}: {Properties.Resources.Enabled}"); } var key = result.Item; var sb = new StringBuilder(); sb.AppendLine(key.Name); foreach (var vd in key.GetValues()) { sb.Append("@=\""); sb.Append(vd.Key); sb.Append("\""); sb.AppendLine(); } tcRegistry.AddTelemetryItem(key, sb.ToString()); keys.Add(key); } } _telemetryKeys = keys; }
private void RefreshTelemetryTasks(bool logging) { var tasks = new List <Task>(); var taskQueries = NvidiaController.GetTelemetryTasks(); if (taskQueries.Count > 0) { foreach (var query in taskQueries) { if (query.Result == null) { if (logging) { AppendLog($"Failed to find task: {query.Query}"); } } else { if (logging) { AppendLog($"Found Task: {query.Result.Name}"); AppendLog($"Task is: {(query.Result.Enabled ? "Enabled" : "Disabled")}"); } if (!query.Result.Enabled) { _tasksControl.DisabledCount++; } _tasksControl.AddSubAction($"Task: {query.Result.Path}", query.Result.Enabled); tasks.Add(query.Result); } } } _tasksControl.Enabled = !_tasksControl.IsEmpty; _telemetryTasks = tasks; }
private void TcRegistry_OnTelemetryChanging(object sender, TelemetryControl.TelemetryEventArgs e) { var telemetry = (TelemetryRegistryKey)e.Telemetry; if (e.Enabled) { var result = NvidiaController.EnableTelemetryRegistryItem(telemetry); if (result.Error != null) { e.Cancel = true; CustomMessageBox.Show( Properties.Resources.Failed_to_enable_registry_item, Properties.Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error); } Logging.GetFileLogger().Log(Level.Info, result.Error != null ? $"{Properties.Resources.Failed_to_enable_registry_item}: {result.Item.Name}" : $"{Properties.Resources.Registry_item_enabled}: {result.Item.Name}"); } else { var result = NvidiaController.DisableTelemetryRegistryItem(telemetry); if (result.Error != null) { e.Cancel = true; CustomMessageBox.Show( Properties.Resources.Failed_to_disable_registry_item, Properties.Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error); } Logging.GetFileLogger().Log(Level.Info, result.Error != null ? $"{Properties.Resources.Failed_to_disable_registry_item}: {result.Item.Name}" : $"{Properties.Resources.Registry_item_disabled}: {result.Item.Name}"); } }
private void tcServices_DefaultClicked(object sender, EventArgs e) { tcServices.Reset(); foreach (var item in _telemetryServices) { var result = NvidiaController.EnableTelemetryServiceStartup(item); Logging.GetFileLogger().Log(Level.Info, result.Error != null ? $"{Properties.Resources.Automatic_service_startup_failed}: {item.Service.DisplayName} ({item.Service.ServiceName})" : $"{Properties.Resources.Automatic_service_startup_enabled}: {item.Service.DisplayName} ({item.Service.ServiceName})"); } foreach (var item in _telemetryServices) { var result = NvidiaController.EnableTelemetryService(item); Logging.GetFileLogger().Log(Level.Info, result.Error != null ? $"{Properties.Resources.Failed_to_start_service}: {item.Service.DisplayName} ({item.Service.ServiceName})" : $"{Properties.Resources.Service_started}: {item.Service.DisplayName} ({item.Service.ServiceName})"); } RefreshTelemetryServices(false); }
private static void SilentlyDisableTelemetry() { Logging.GetFileLogger().Log(Level.Info, DisableNvidiaTelemetry.Properties.Resources.Silently_disabling_telemetry_services); foreach (var serviceResult in NvidiaController.EnumerateTelemetryServices().ToList()) { if (serviceResult.Error == null) { var startupResult = NvidiaController.DisableTelemetryServiceStartup(serviceResult.Item); Logging.GetFileLogger().Log(Level.Info, startupResult.Error != null ? $"{DisableNvidiaTelemetry.Properties.Resources.Disable_service_startup_failed}: {serviceResult.Item.Service.DisplayName} ({serviceResult.Item.Service.ServiceName})" : $"{DisableNvidiaTelemetry.Properties.Resources.Automatic_service_startup_disabled}: {serviceResult.Item.Service.DisplayName} ({serviceResult.Item.Service.ServiceName})"); Logging.GetEventLogger().Log(Level.Info, startupResult.Error != null ? $"{DisableNvidiaTelemetry.Properties.Resources.Disable_service_startup_failed}: {serviceResult.Item.Service.DisplayName} ({serviceResult.Item.Service.ServiceName})" : $"{DisableNvidiaTelemetry.Properties.Resources.Automatic_service_startup_disabled}: {serviceResult.Item.Service.DisplayName} ({serviceResult.Item.Service.ServiceName})"); var result = NvidiaController.DisableTelemetryService(serviceResult.Item); Logging.GetFileLogger().Log(Level.Info, result.Error != null ? $"{DisableNvidiaTelemetry.Properties.Resources.Failed_to_stop_service}: {serviceResult.Item.Service.DisplayName} ({serviceResult.Item.Service.ServiceName})" : $"{DisableNvidiaTelemetry.Properties.Resources.Service_stopped}: {serviceResult.Item.Service.DisplayName} ({serviceResult.Item.Service.ServiceName})"); Logging.GetEventLogger().Log(Level.Info, result.Error != null ? $"{DisableNvidiaTelemetry.Properties.Resources.Failed_to_stop_service}: {serviceResult.Item.Service.DisplayName} ({serviceResult.Item.Service.ServiceName})" : $"{DisableNvidiaTelemetry.Properties.Resources.Service_stopped}: {serviceResult.Item.Service.DisplayName} ({serviceResult.Item.Service.ServiceName})"); } } Logging.GetFileLogger().Log(Level.Info, DisableNvidiaTelemetry.Properties.Resources.Silently_disabling_telemetry_tasks); foreach (var taskResult in NvidiaController.EnumerateTelemetryTasks().ToList()) { if (taskResult.Error == null) { var result = NvidiaController.DisableTelemetryTask(taskResult.Item); Logging.GetFileLogger().Log(Level.Info, result.Error != null ? $"{DisableNvidiaTelemetry.Properties.Resources.Failed_to_disable_task}: {result.Item.Task.Path}" : $"{DisableNvidiaTelemetry.Properties.Resources.Task_disabled}: {result.Item.Task.Path}"); Logging.GetEventLogger().Log(Level.Info, result.Error != null ? $"{DisableNvidiaTelemetry.Properties.Resources.Failed_to_disable_task}: {result.Item.Task.Path}" : $"{DisableNvidiaTelemetry.Properties.Resources.Task_disabled}: {result.Item.Task.Path}"); } else { Logging.GetFileLogger().Log(Level.Error, taskResult.Error); Logging.GetEventLogger().Log(Level.Error, taskResult.Error); } } Logging.GetFileLogger().Log(Level.Info, DisableNvidiaTelemetry.Properties.Resources.Silently_disabling_telemetry_registry_items); foreach (var registryResult in NvidiaController.EnumerateTelemetryRegistryItems().ToList()) { if (registryResult.Error == null) { var result = NvidiaController.DisableTelemetryRegistryItem(registryResult.Item); Logging.GetFileLogger().Log(Level.Info, result.Error != null ? $"{DisableNvidiaTelemetry.Properties.Resources.Failed_to_disable_registry_item}: {result.Item.Name}" : $"{DisableNvidiaTelemetry.Properties.Resources.Registry_item_disabled}: {result.Item.Name}"); Logging.GetEventLogger().Log(Level.Info, result.Error != null ? $"{DisableNvidiaTelemetry.Properties.Resources.Failed_to_disable_registry_item}: {result.Item.Name}" : $"{DisableNvidiaTelemetry.Properties.Resources.Registry_item_disabled}: {result.Item.Name}"); } } }