/// <summary> /// Entire record refresh. /// </summary> public void EntireRefresh() { // TODO Here we have a bug. If i change Display name Controller doesn't refresh it, so we retake service Controller = ServiceController.GetServices().Single(s => s.ServiceName == Controller.ServiceName); WinServiceUtils.TryGetServiceConfig(Controller.ServiceName, out _serviceConfig); RaisePropertiesChanged(); }
async Task <bool> Prepare() { bool enabled = WinServiceUtils.TrySetStartupType(WinUpdatesManager.WUA_SERVICE_NAME, true); if (!enabled) { return(false); } return(await WinServiceUtils.StartServiceAsync(WinUpdatesManager.WUA_SERVICE_NAME, 60000).ConfigureAwait(false)); }
private async void stopService_Click(object sender, RoutedEventArgs e) { LogUpdateInto("stopping service..."); bool result = await WinServiceUtils.StopServiceAsync("wuauserv", 5000); if (result) { LogUpdateInto("success!"); } else { LogUpdateInto("fail!"); } }
public override bool Execute() { try { var name = Params[PARAM_NAME_SERVICE_NAME]; var mode = NormalizeStartMode(Params[PARAM_NAME_START_MODE]); WinServiceUtils.SetStartupType(name, mode); return(true); } catch (Exception e) { Log.Error("ServiceAction.Execute", e.ToString()); return(false); } }
public override StatusResult CheckStatus() { try { var name = Params[PARAM_NAME_SERVICE_NAME]; var mode = NormalizeStartMode(Params[PARAM_NAME_START_MODE]); var actualMode = WinServiceUtils.GetStartupType(name); if (actualMode.ToLower() == mode.ToLower()) { return(StatusResult.Match); } else { return(StatusResult.Mismatch); } } catch (Exception e) { Log.Error("ServiceAction.CheckStatus", e.ToString()); return(StatusResult.Unavailable); } }
async Task Cleanup() { //unregister all events //todo is this really necessary: considering that //this reference lives here in the Page only if (winUpdateManager != null) { winUpdateManager.CheckCompleted -= WinUpdateManager_CheckCompleted; winUpdateManager.DownloadCompleted -= WinUpdateManager_DownloadCompleted; winUpdateManager.InstallationCompleted -= WinUpdateManager_InstallationCompleted; winUpdateManager.ProgressChanged -= WinUpdateManager_ProgressChanged; //in case there is still somehting going on at the moment //todo can this cause problems? //winUpdateManager.AbortAll(); winUpdateManager.CleanUp(); winUpdateManager = null; } await WinServiceUtils.StopServiceAsync(WinUpdatesManager.WUA_SERVICE_NAME, 60000).ConfigureAwait(false); WinServiceUtils.TrySetStartupType(WinUpdatesManager.WUA_SERVICE_NAME, false); }
/// <summary> /// Constructor for <see cref="ServiceModel"/>. /// </summary> public ServiceModel(ServiceController service) { Controller = service; WinServiceUtils.TryGetServiceConfig(Controller.ServiceName, out _serviceConfig); }
private void disableService_Click(object sender, RoutedEventArgs e) { WinServiceUtils.DisableService("wuauserv"); }