コード例 #1
0
        private void TcServices_OnTelemetryChanging(object sender, TelemetryControl.TelemetryEventArgs e)
        {
            var telemetry = (TelemetryService)e.Telemetry;

            if (e.Enabled)
            {
                var startupResult = NvidiaController.EnableTelemetryServiceStartup(telemetry);

                Logging.GetFileLogger().Log(Level.Info, startupResult.Error != null
                    ? $"{Properties.Resources.Automatic_service_startup_failed}: {telemetry.Service.DisplayName} ({telemetry.Service.ServiceName})"
                    : $"{Properties.Resources.Automatic_service_startup_enabled}: {telemetry.Service.DisplayName} ({telemetry.Service.ServiceName})");

                var result = NvidiaController.EnableTelemetryService(telemetry);

                Logging.GetFileLogger().Log(Level.Info, result.Error != null
                    ? $"{Properties.Resources.Failed_to_start_service}: {telemetry.Service.DisplayName} ({telemetry.Service.ServiceName})"
                    : $"{Properties.Resources.Service_started}: {telemetry.Service.DisplayName} ({telemetry.Service.ServiceName})");
            }

            else
            {
                var startupResult = NvidiaController.DisableTelemetryServiceStartup(telemetry);

                Logging.GetFileLogger().Log(Level.Info, startupResult.Error != null
                    ? $"{Properties.Resources.Disable_service_startup_failed}: {telemetry.Service.DisplayName} ({telemetry.Service.ServiceName})"
                    : $"{Properties.Resources.Automatic_service_startup_disabled}: {telemetry.Service.DisplayName} ({telemetry.Service.ServiceName})");

                var result = NvidiaController.DisableTelemetryService(telemetry);

                Logging.GetFileLogger().Log(Level.Info, result.Error != null
                    ? $"{Properties.Resources.Failed_to_stop_service}: {telemetry.Service.DisplayName} ({telemetry.Service.ServiceName})"
                    : $"{Properties.Resources.Service_stopped}: {telemetry.Service.DisplayName} ({telemetry.Service.ServiceName})");
            }
        }
コード例 #2
0
        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}");
                }
            }
        }