private void CheckRefresh(TweakEntry entry) { RefreshRequiredAttribute attribute = entry.GetAttribute <RefreshRequiredAttribute>(); if (attribute == null) { return; } if (attribute.Type == RestartType.ExplorerRestart) { DialogResult result = MessageBox.Show(Properties.Strings.Reload_ExplorerRestart, Properties.Strings.Application_Name, MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { Program.RestartExplorer(); } } else if (attribute.Type == RestartType.SystemRestart) { DialogResult result = MessageBox.Show(Properties.Strings.Reload_SystemRestart, Properties.Strings.Application_Name, MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { NativeMethods.ExitWindowsEx(NativeMethods.ExitWindows.Reboot, NativeMethods.ShutdownReason.MinorReconfig); } } else if (attribute.Type == RestartType.ProcessRestart) { DialogResult result = MessageBox.Show(string.Format(Properties.Strings.Reload_ProcessRestart, attribute.Argument), Properties.Strings.Application_Name, MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { var processes = Process.GetProcessesByName(attribute.Argument); using (var indicator = new ProgressIndicator()) { indicator.Initialize(processes.Length); foreach (Process process in processes) { string fileName = process.MainModule.FileName; indicator.SetProgress(-1, string.Format(Properties.Strings.Reload_ProcessRestart_WaitingFor, fileName)); if (!process.CloseMainWindow() && !process.HasExited && !process.WaitForExit(10000)) { process.Kill(); } Process.Start(fileName); } indicator.SetProgress(processes.Length, ""); } } } else if (attribute.Type == RestartType.ServiceRestart) { using (var controller = new ServiceController(attribute.Argument)) { var result = MessageBox.Show(string.Format(Properties.Strings.Reload_ServiceRestart, controller.DisplayName, controller.ServiceName), Properties.Strings.Application_Name, MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { using (var indicator = new ProgressIndicator()) { indicator.Initialize(1); indicator.SetProgress(-1, string.Format(Properties.Strings.Reload_ServiceRestart_Text, controller.DisplayName)); controller.Stop(); controller.WaitForStatus(ServiceControllerStatus.Stopped); controller.Start(); controller.WaitForStatus(ServiceControllerStatus.Running); indicator.SetProgress(1, ""); } } } } else if (attribute.Type == RestartType.Logoff) { DialogResult result = MessageBox.Show(Properties.Strings.Reload_LogOff, Properties.Strings.Application_Name, MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { NativeMethods.ExitWindowsEx(NativeMethods.ExitWindows.LogOff, NativeMethods.ShutdownReason.MinorReconfig); } } else if (attribute.Type == RestartType.TweakUtility) { DialogResult result = MessageBox.Show(Properties.Strings.Reload_TweakUtility, Properties.Strings.Application_Name, MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { Application.Restart(); } } else if (attribute.Type == RestartType.Unknown) { MessageBox.Show(Properties.Strings.Reload_Unknown, Properties.Strings.Application_Name, MessageBoxButtons.OK, MessageBoxIcon.Information); } }