ApplicationHost.cs 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593
  1. using MediaBrowser.Api;
  2. using MediaBrowser.Common;
  3. using MediaBrowser.Common.Configuration;
  4. using MediaBrowser.Common.Constants;
  5. using MediaBrowser.Common.Extensions;
  6. using MediaBrowser.Common.Implementations;
  7. using MediaBrowser.Common.Implementations.ScheduledTasks;
  8. using MediaBrowser.Common.IO;
  9. using MediaBrowser.Common.MediaInfo;
  10. using MediaBrowser.Common.Net;
  11. using MediaBrowser.Controller;
  12. using MediaBrowser.Controller.Configuration;
  13. using MediaBrowser.Controller.Drawing;
  14. using MediaBrowser.Controller.Entities;
  15. using MediaBrowser.Controller.IO;
  16. using MediaBrowser.Controller.Library;
  17. using MediaBrowser.Controller.Localization;
  18. using MediaBrowser.Controller.MediaInfo;
  19. using MediaBrowser.Controller.Persistence;
  20. using MediaBrowser.Controller.Plugins;
  21. using MediaBrowser.Controller.Providers;
  22. using MediaBrowser.Controller.Resolvers;
  23. using MediaBrowser.Controller.Session;
  24. using MediaBrowser.Controller.Sorting;
  25. using MediaBrowser.Controller.Updates;
  26. using MediaBrowser.Controller.Weather;
  27. using MediaBrowser.IsoMounter;
  28. using MediaBrowser.Model.IO;
  29. using MediaBrowser.Model.MediaInfo;
  30. using MediaBrowser.Model.System;
  31. using MediaBrowser.Model.Updates;
  32. using MediaBrowser.Server.Implementations;
  33. using MediaBrowser.Server.Implementations.BdInfo;
  34. using MediaBrowser.Server.Implementations.Configuration;
  35. using MediaBrowser.Server.Implementations.HttpServer;
  36. using MediaBrowser.Server.Implementations.IO;
  37. using MediaBrowser.Server.Implementations.Library;
  38. using MediaBrowser.Server.Implementations.Localization;
  39. using MediaBrowser.Server.Implementations.MediaEncoder;
  40. using MediaBrowser.Server.Implementations.Providers;
  41. using MediaBrowser.Server.Implementations.ServerManager;
  42. using MediaBrowser.Server.Implementations.Session;
  43. using MediaBrowser.Server.Implementations.Sqlite;
  44. using MediaBrowser.Server.Implementations.Updates;
  45. using MediaBrowser.Server.Implementations.WebSocket;
  46. using MediaBrowser.ServerApplication.Implementations;
  47. using MediaBrowser.WebDashboard.Api;
  48. using System;
  49. using System.Collections.Generic;
  50. using System.Diagnostics;
  51. using System.IO;
  52. using System.Linq;
  53. using System.Reflection;
  54. using System.Threading;
  55. using System.Threading.Tasks;
  56. namespace MediaBrowser.ServerApplication
  57. {
  58. /// <summary>
  59. /// Class CompositionRoot
  60. /// </summary>
  61. public class ApplicationHost : BaseApplicationHost<ServerApplicationPaths>, IServerApplicationHost
  62. {
  63. internal const int UdpServerPort = 7359;
  64. /// <summary>
  65. /// Gets the server kernel.
  66. /// </summary>
  67. /// <value>The server kernel.</value>
  68. protected Kernel ServerKernel { get; set; }
  69. /// <summary>
  70. /// Gets the server configuration manager.
  71. /// </summary>
  72. /// <value>The server configuration manager.</value>
  73. public IServerConfigurationManager ServerConfigurationManager
  74. {
  75. get { return (IServerConfigurationManager)ConfigurationManager; }
  76. }
  77. /// <summary>
  78. /// Gets the name of the log file prefix.
  79. /// </summary>
  80. /// <value>The name of the log file prefix.</value>
  81. protected override string LogFilePrefixName
  82. {
  83. get { return "server"; }
  84. }
  85. /// <summary>
  86. /// Gets the name of the web application that can be used for url building.
  87. /// All api urls will be of the form {protocol}://{host}:{port}/{appname}/...
  88. /// </summary>
  89. /// <value>The name of the web application.</value>
  90. public string WebApplicationName
  91. {
  92. get { return "mediabrowser"; }
  93. }
  94. /// <summary>
  95. /// Gets the HTTP server URL prefix.
  96. /// </summary>
  97. /// <value>The HTTP server URL prefix.</value>
  98. public string HttpServerUrlPrefix
  99. {
  100. get
  101. {
  102. return "http://+:" + ServerConfigurationManager.Configuration.HttpServerPortNumber + "/" + WebApplicationName + "/";
  103. }
  104. }
  105. /// <summary>
  106. /// Gets the configuration manager.
  107. /// </summary>
  108. /// <returns>IConfigurationManager.</returns>
  109. protected override IConfigurationManager GetConfigurationManager()
  110. {
  111. return new ServerConfigurationManager(ApplicationPaths, LogManager, XmlSerializer);
  112. }
  113. /// <summary>
  114. /// Gets or sets the installation manager.
  115. /// </summary>
  116. /// <value>The installation manager.</value>
  117. private IInstallationManager InstallationManager { get; set; }
  118. /// <summary>
  119. /// Gets or sets the server manager.
  120. /// </summary>
  121. /// <value>The server manager.</value>
  122. private IServerManager ServerManager { get; set; }
  123. /// <summary>
  124. /// Gets or sets the user manager.
  125. /// </summary>
  126. /// <value>The user manager.</value>
  127. public IUserManager UserManager { get; set; }
  128. /// <summary>
  129. /// Gets or sets the library manager.
  130. /// </summary>
  131. /// <value>The library manager.</value>
  132. internal ILibraryManager LibraryManager { get; set; }
  133. /// <summary>
  134. /// Gets or sets the directory watchers.
  135. /// </summary>
  136. /// <value>The directory watchers.</value>
  137. private IDirectoryWatchers DirectoryWatchers { get; set; }
  138. /// <summary>
  139. /// Gets or sets the provider manager.
  140. /// </summary>
  141. /// <value>The provider manager.</value>
  142. private IProviderManager ProviderManager { get; set; }
  143. /// <summary>
  144. /// Gets or sets the zip client.
  145. /// </summary>
  146. /// <value>The zip client.</value>
  147. private IZipClient ZipClient { get; set; }
  148. /// <summary>
  149. /// Gets or sets the HTTP server.
  150. /// </summary>
  151. /// <value>The HTTP server.</value>
  152. private IHttpServer HttpServer { get; set; }
  153. /// <summary>
  154. /// Gets or sets the display preferences manager.
  155. /// </summary>
  156. /// <value>The display preferences manager.</value>
  157. internal IDisplayPreferencesManager DisplayPreferencesManager { get; set; }
  158. /// <summary>
  159. /// Gets or sets the media encoder.
  160. /// </summary>
  161. /// <value>The media encoder.</value>
  162. private IMediaEncoder MediaEncoder { get; set; }
  163. /// <summary>
  164. /// Gets or sets the user data repository.
  165. /// </summary>
  166. /// <value>The user data repository.</value>
  167. private IUserDataRepository UserDataRepository { get; set; }
  168. private IUserRepository UserRepository { get; set; }
  169. private IDisplayPreferencesRepository DisplayPreferencesRepository { get; set; }
  170. private IItemRepository ItemRepository { get; set; }
  171. /// <summary>
  172. /// The full path to our startmenu shortcut
  173. /// </summary>
  174. protected override string ProductShortcutPath
  175. {
  176. get { return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.StartMenu), "Media Browser 3", "Media Browser Server.lnk"); }
  177. }
  178. private Task<IHttpServer> _httpServerCreationTask;
  179. /// <summary>
  180. /// Runs the startup tasks.
  181. /// </summary>
  182. /// <returns>Task.</returns>
  183. public override async Task RunStartupTasks()
  184. {
  185. await base.RunStartupTasks().ConfigureAwait(false);
  186. DirectoryWatchers.Start();
  187. Logger.Info("Core startup complete");
  188. Parallel.ForEach(GetExports<IServerEntryPoint>(), entryPoint => entryPoint.Run());
  189. }
  190. /// <summary>
  191. /// Called when [logger loaded].
  192. /// </summary>
  193. protected override void OnLoggerLoaded()
  194. {
  195. base.OnLoggerLoaded();
  196. _httpServerCreationTask = Task.Run(() => ServerFactory.CreateServer(this, LogManager, "Media Browser", "dashboard/index.html"));
  197. }
  198. /// <summary>
  199. /// Registers resources that classes will depend on
  200. /// </summary>
  201. /// <returns>Task.</returns>
  202. protected override async Task RegisterResources()
  203. {
  204. ServerKernel = new Kernel();
  205. await base.RegisterResources().ConfigureAwait(false);
  206. RegisterSingleInstance<IHttpResultFactory>(new HttpResultFactory(LogManager));
  207. RegisterSingleInstance<IServerApplicationHost>(this);
  208. RegisterSingleInstance<IServerApplicationPaths>(ApplicationPaths);
  209. RegisterSingleInstance(ServerKernel);
  210. RegisterSingleInstance(ServerConfigurationManager);
  211. RegisterSingleInstance<IWebSocketServer>(() => new AlchemyServer(Logger));
  212. RegisterSingleInstance<IIsoManager>(() => new PismoIsoManager(Logger));
  213. RegisterSingleInstance<IBlurayExaminer>(() => new BdInfoExaminer());
  214. ZipClient = new DotNetZipClient();
  215. RegisterSingleInstance(ZipClient);
  216. UserDataRepository = new SQLiteUserDataRepository(ApplicationPaths, JsonSerializer, LogManager);
  217. RegisterSingleInstance(UserDataRepository);
  218. UserRepository = new SQLiteUserRepository(ApplicationPaths, JsonSerializer, LogManager);
  219. RegisterSingleInstance(UserRepository);
  220. DisplayPreferencesRepository = new SQLiteDisplayPreferencesRepository(ApplicationPaths, JsonSerializer, LogManager);
  221. RegisterSingleInstance(DisplayPreferencesRepository);
  222. ItemRepository = new SQLiteItemRepository(ApplicationPaths, JsonSerializer, LogManager);
  223. RegisterSingleInstance(ItemRepository);
  224. UserManager = new UserManager(Logger, ServerConfigurationManager);
  225. RegisterSingleInstance(UserManager);
  226. LibraryManager = new LibraryManager(Logger, TaskManager, UserManager, ServerConfigurationManager, UserDataRepository);
  227. RegisterSingleInstance(LibraryManager);
  228. InstallationManager = new InstallationManager(HttpClient, PackageManager, JsonSerializer, Logger, this);
  229. RegisterSingleInstance(InstallationManager);
  230. DirectoryWatchers = new DirectoryWatchers(LogManager, TaskManager, LibraryManager, ServerConfigurationManager);
  231. RegisterSingleInstance(DirectoryWatchers);
  232. ProviderManager = new ProviderManager(HttpClient, ServerConfigurationManager, DirectoryWatchers, LogManager);
  233. RegisterSingleInstance(ProviderManager);
  234. DisplayPreferencesManager = new DisplayPreferencesManager(LogManager.GetLogger("DisplayPreferencesManager"));
  235. RegisterSingleInstance(DisplayPreferencesManager);
  236. RegisterSingleInstance<ILibrarySearchEngine>(() => new LuceneSearchEngine(ApplicationPaths, LogManager, LibraryManager));
  237. MediaEncoder = new MediaEncoder(LogManager.GetLogger("MediaEncoder"), ZipClient, ApplicationPaths, JsonSerializer);
  238. RegisterSingleInstance(MediaEncoder);
  239. var clientConnectionManager = new SessionManager(UserDataRepository, ServerConfigurationManager, Logger, UserRepository);
  240. RegisterSingleInstance<ISessionManager>(clientConnectionManager);
  241. HttpServer = await _httpServerCreationTask.ConfigureAwait(false);
  242. RegisterSingleInstance(HttpServer, false);
  243. ServerManager = new ServerManager(this, JsonSerializer, Logger, ServerConfigurationManager);
  244. RegisterSingleInstance(ServerManager);
  245. var localizationManager = new LocalizationManager();
  246. RegisterSingleInstance<ILocalizationManager>(localizationManager);
  247. var displayPreferencesTask = Task.Run(async () => await ConfigureDisplayPreferencesRepositories().ConfigureAwait(false));
  248. var itemsTask = Task.Run(async () => await ConfigureItemRepositories().ConfigureAwait(false));
  249. var userdataTask = Task.Run(async () => await ConfigureUserDataRepositories().ConfigureAwait(false));
  250. var userTask = Task.Run(async () => await ConfigureUserRepositories().ConfigureAwait(false));
  251. await Task.WhenAll(itemsTask, userTask, displayPreferencesTask, userdataTask).ConfigureAwait(false);
  252. SetKernelProperties();
  253. }
  254. /// <summary>
  255. /// Sets the kernel properties.
  256. /// </summary>
  257. private void SetKernelProperties()
  258. {
  259. ServerKernel.ImageManager = new ImageManager(ServerKernel, LogManager.GetLogger("ImageManager"),
  260. ApplicationPaths);
  261. Parallel.Invoke(
  262. () => ServerKernel.FFMpegManager = new FFMpegManager(ApplicationPaths, MediaEncoder, LibraryManager, Logger),
  263. () => ServerKernel.WeatherProviders = GetExports<IWeatherProvider>(),
  264. () => ServerKernel.ImageManager.ImageEnhancers = GetExports<IImageEnhancer>().OrderBy(e => e.Priority).ToArray(),
  265. () => LocalizedStrings.StringFiles = GetExports<LocalizedStringData>(),
  266. SetStaticProperties
  267. );
  268. }
  269. /// <summary>
  270. /// Configures the repositories.
  271. /// </summary>
  272. /// <returns>Task.</returns>
  273. private async Task ConfigureDisplayPreferencesRepositories()
  274. {
  275. await DisplayPreferencesRepository.Initialize().ConfigureAwait(false);
  276. ((DisplayPreferencesManager)DisplayPreferencesManager).Repository = DisplayPreferencesRepository;
  277. }
  278. /// <summary>
  279. /// Configures the item repositories.
  280. /// </summary>
  281. /// <returns>Task.</returns>
  282. private async Task ConfigureItemRepositories()
  283. {
  284. await ItemRepository.Initialize().ConfigureAwait(false);
  285. ((LibraryManager)LibraryManager).ItemRepository = ItemRepository;
  286. }
  287. /// <summary>
  288. /// Configures the user data repositories.
  289. /// </summary>
  290. /// <returns>Task.</returns>
  291. private Task ConfigureUserDataRepositories()
  292. {
  293. return UserDataRepository.Initialize();
  294. }
  295. /// <summary>
  296. /// Configures the user repositories.
  297. /// </summary>
  298. /// <returns>Task.</returns>
  299. private async Task ConfigureUserRepositories()
  300. {
  301. await UserRepository.Initialize().ConfigureAwait(false);
  302. ((UserManager)UserManager).UserRepository = UserRepository;
  303. }
  304. /// <summary>
  305. /// Dirty hacks
  306. /// </summary>
  307. private void SetStaticProperties()
  308. {
  309. // For now there's no real way to inject these properly
  310. BaseItem.Logger = LogManager.GetLogger("BaseItem");
  311. BaseItem.ConfigurationManager = ServerConfigurationManager;
  312. BaseItem.LibraryManager = LibraryManager;
  313. BaseItem.ProviderManager = ProviderManager;
  314. User.XmlSerializer = XmlSerializer;
  315. User.UserManager = UserManager;
  316. Ratings.ConfigurationManager = ServerConfigurationManager;
  317. LocalizedStrings.ApplicationPaths = ApplicationPaths;
  318. }
  319. /// <summary>
  320. /// Finds the parts.
  321. /// </summary>
  322. protected override void FindParts()
  323. {
  324. if (IsFirstRun)
  325. {
  326. RegisterServerWithAdministratorAccess();
  327. }
  328. base.FindParts();
  329. HttpServer.Init(GetExports<IRestfulService>(false));
  330. ServerManager.AddWebSocketListeners(GetExports<IWebSocketListener>(false));
  331. StartServer(true);
  332. LibraryManager.AddParts(GetExports<IResolverIgnoreRule>(),
  333. GetExports<IVirtualFolderCreator>(),
  334. GetExports<IItemResolver>(),
  335. GetExports<IIntroProvider>(),
  336. GetExports<IBaseItemComparer>(),
  337. GetExports<ILibraryPrescanTask>(),
  338. GetExports<ILibraryPostScanTask>());
  339. ProviderManager.AddMetadataProviders(GetExports<BaseMetadataProvider>().ToArray());
  340. }
  341. /// <summary>
  342. /// Starts the server.
  343. /// </summary>
  344. /// <param name="retryOnFailure">if set to <c>true</c> [retry on failure].</param>
  345. private void StartServer(bool retryOnFailure)
  346. {
  347. try
  348. {
  349. ServerManager.Start();
  350. }
  351. catch
  352. {
  353. if (retryOnFailure)
  354. {
  355. RegisterServerWithAdministratorAccess();
  356. StartServer(false);
  357. }
  358. else
  359. {
  360. throw;
  361. }
  362. }
  363. }
  364. /// <summary>
  365. /// Called when [configuration updated].
  366. /// </summary>
  367. /// <param name="sender">The sender.</param>
  368. /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  369. protected override void OnConfigurationUpdated(object sender, EventArgs e)
  370. {
  371. base.OnConfigurationUpdated(sender, e);
  372. if (!string.Equals(HttpServer.UrlPrefix, HttpServerUrlPrefix, StringComparison.OrdinalIgnoreCase))
  373. {
  374. NotifyPendingRestart();
  375. }
  376. else if (!ServerManager.SupportsNativeWebSocket && ServerManager.WebSocketPortNumber != ServerConfigurationManager.Configuration.LegacyWebSocketPortNumber)
  377. {
  378. NotifyPendingRestart();
  379. }
  380. }
  381. /// <summary>
  382. /// Restarts this instance.
  383. /// </summary>
  384. public override void Restart()
  385. {
  386. App.Instance.Restart();
  387. }
  388. /// <summary>
  389. /// Gets or sets a value indicating whether this instance can self update.
  390. /// </summary>
  391. /// <value><c>true</c> if this instance can self update; otherwise, <c>false</c>.</value>
  392. public override bool CanSelfUpdate
  393. {
  394. get { return ConfigurationManager.CommonConfiguration.EnableAutoUpdate; }
  395. }
  396. /// <summary>
  397. /// Checks for update.
  398. /// </summary>
  399. /// <param name="cancellationToken">The cancellation token.</param>
  400. /// <param name="progress">The progress.</param>
  401. /// <returns>Task{CheckForUpdateResult}.</returns>
  402. public async override Task<CheckForUpdateResult> CheckForApplicationUpdate(CancellationToken cancellationToken, IProgress<double> progress)
  403. {
  404. var availablePackages = await PackageManager.GetAvailablePackages(CancellationToken.None).ConfigureAwait(false);
  405. var version = InstallationManager.GetLatestCompatibleVersion(availablePackages, Constants.MbServerPkgName, ConfigurationManager.CommonConfiguration.SystemUpdateLevel);
  406. return version != null ? new CheckForUpdateResult { AvailableVersion = version.version, IsUpdateAvailable = version.version > ApplicationVersion, Package = version } :
  407. new CheckForUpdateResult { AvailableVersion = ApplicationVersion, IsUpdateAvailable = false };
  408. }
  409. /// <summary>
  410. /// Gets the composable part assemblies.
  411. /// </summary>
  412. /// <returns>IEnumerable{Assembly}.</returns>
  413. protected override IEnumerable<Assembly> GetComposablePartAssemblies()
  414. {
  415. // Gets all plugin assemblies by first reading all bytes of the .dll and calling Assembly.Load against that
  416. // This will prevent the .dll file from getting locked, and allow us to replace it when needed
  417. foreach (var pluginAssembly in Directory
  418. .EnumerateFiles(ApplicationPaths.PluginsPath, "*.dll", SearchOption.TopDirectoryOnly)
  419. .Select(LoadAssembly).Where(a => a != null))
  420. {
  421. yield return pluginAssembly;
  422. }
  423. // Include composable parts in the Api assembly
  424. yield return typeof(ApiEntryPoint).Assembly;
  425. // Include composable parts in the Dashboard assembly
  426. yield return typeof(DashboardInfo).Assembly;
  427. // Include composable parts in the Model assembly
  428. yield return typeof(SystemInfo).Assembly;
  429. // Include composable parts in the Common assembly
  430. yield return typeof(IApplicationHost).Assembly;
  431. // Include composable parts in the Controller assembly
  432. yield return typeof(Kernel).Assembly;
  433. // Common implementations
  434. yield return typeof(TaskManager).Assembly;
  435. // Server implementations
  436. yield return typeof(ServerApplicationPaths).Assembly;
  437. // Include composable parts in the running assembly
  438. yield return GetType().Assembly;
  439. }
  440. private readonly string _systemId = Environment.MachineName.GetMD5().ToString();
  441. /// <summary>
  442. /// Gets the system status.
  443. /// </summary>
  444. /// <returns>SystemInfo.</returns>
  445. public virtual SystemInfo GetSystemInfo()
  446. {
  447. return new SystemInfo
  448. {
  449. HasPendingRestart = HasPendingRestart,
  450. Version = ApplicationVersion.ToString(),
  451. IsNetworkDeployed = CanSelfUpdate,
  452. WebSocketPortNumber = ServerManager.WebSocketPortNumber,
  453. SupportsNativeWebSocket = ServerManager.SupportsNativeWebSocket,
  454. FailedPluginAssemblies = FailedAssemblies.ToArray(),
  455. InProgressInstallations = InstallationManager.CurrentInstallations.Select(i => i.Item1).ToArray(),
  456. CompletedInstallations = InstallationManager.CompletedInstallations.ToArray(),
  457. Id = _systemId,
  458. ProgramDataPath = ApplicationPaths.ProgramDataPath
  459. };
  460. }
  461. /// <summary>
  462. /// Shuts down.
  463. /// </summary>
  464. public override void Shutdown()
  465. {
  466. App.Instance.Dispatcher.Invoke(App.Instance.Shutdown);
  467. }
  468. /// <summary>
  469. /// Registers the server with administrator access.
  470. /// </summary>
  471. private void RegisterServerWithAdministratorAccess()
  472. {
  473. Logger.Info("Requesting administrative access to authorize http server");
  474. // Create a temp file path to extract the bat file to
  475. var tmpFile = Path.Combine(ConfigurationManager.CommonApplicationPaths.TempDirectory, Guid.NewGuid() + ".bat");
  476. // Extract the bat file
  477. using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("MediaBrowser.ServerApplication.RegisterServer.bat"))
  478. {
  479. using (var fileStream = File.Create(tmpFile))
  480. {
  481. stream.CopyTo(fileStream);
  482. }
  483. }
  484. var startInfo = new ProcessStartInfo
  485. {
  486. FileName = tmpFile,
  487. Arguments = string.Format("{0} {1} {2} {3}", ServerConfigurationManager.Configuration.HttpServerPortNumber,
  488. HttpServerUrlPrefix,
  489. UdpServerPort,
  490. ServerConfigurationManager.Configuration.LegacyWebSocketPortNumber),
  491. CreateNoWindow = true,
  492. WindowStyle = ProcessWindowStyle.Hidden,
  493. Verb = "runas",
  494. ErrorDialog = false
  495. };
  496. using (var process = Process.Start(startInfo))
  497. {
  498. process.WaitForExit();
  499. }
  500. }
  501. }
  502. }