/// <summary> /// Install Virtual driver. /// </summary> /// <remarks>Must be executed in administrative mode.</remarks> public static void InstallViGEmBus(ProcessWindowStyle style = ProcessWindowStyle.Hidden) { // Extract files first. ExtractViGemBusFiles(true); var folder = GetViGEmBusPath(); var exePath = Path.Combine(folder, GetDevConPath()); var osString = JocysCom.ClassLibrary.Controls.IssuesControl.IssueHelper.GetRealOSVersion().Major >= 10 ? "Win10" : "WinVS"; var infFile = string.Format("{0}\\{1}", osString, "ViGEmBus.inf"); UacHelper.RunElevated( exePath, // Use last ID. "install " + infFile + " " + ViGEmBusHardwareIds.Last(), style, true); }
/// <summary> /// Uninstall HID Guardian. /// </summary> /// <remarks>Must be executed in administrative mode.</remarks> public static void UninstallHidGuardian(ProcessWindowStyle style = ProcessWindowStyle.Hidden) { // Extract files first. ExtractHidGuardianFiles(); var folder = GetHidGuardianPath(); var exePath = Path.Combine(folder, GetDevConPath()); UacHelper.RunElevated( exePath, "remove " + HidGuardianHardwareId, style, true); UacHelper.RunElevated( exePath, "classfilter HIDClass upper !HidGuardian", style, true); }
public void ConfigureAndRun() { HostFactory.Run( config => { NancyHost nancyHost = null; config.Service <ISchedulerManager>( service => { service.ConstructUsing(settings => _schedulerManager); service.WhenStarted( (schedulerManager, hostControl) => { schedulerManager.Start(); nancyHost = new NancyHost( _nancySelfHostUri, new Bootstrapper(new InteractiveModule(hostControl))); nancyHost.Start(); return(true); }); service.WhenStopped( schedulerManager => { schedulerManager.Stop(); nancyHost?.Stop(); }); service.AfterStoppingService(_ => nancyHost?.Dispose()); }); config.SetServiceName(_serviceName); config.SetDisplayName(_serviceDisplayName); config.RunAsNetworkService(); config.StartAutomatically(); config.UseLog4Net(); config.EnableShutdown(); config.AddCommandLineSwitch("squirrel", _ => { }); config.AddCommandLineDefinition("firstrun", _ => Environment.Exit(0)); config.AddCommandLineDefinition("updated", version => { // nancy self host var url = new UriBuilder(_nancySelfHostUri) { Host = "+", Path = _serviceName }.ToString(); UacHelper.RunElevated("netsh", $"http add urlacl url=\"{url}\" user=\"Everyone\""); // topshelf config.UseHostBuilder((env, settings) => new UpdateHostBuilder(env, settings, version)); }); config.AddCommandLineDefinition("obsolete", _ => Environment.Exit(0)); config.AddCommandLineDefinition("install", _ => Environment.Exit(0)); config.AddCommandLineDefinition("uninstall", _ => { // nancy self host var url = new UriBuilder(_nancySelfHostUri) { Host = "+", Path = _serviceName }.ToString(); UacHelper.RunElevated("netsh", $"http delete urlacl url=\"{url}\""); // topshelf config.UseHostBuilder((env, settings) => new StopAndUninstallHostBuilder(env, settings)); }); }); }