ApplicationHost.cs 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598
  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.IsoMounter;
  27. using MediaBrowser.Model.IO;
  28. using MediaBrowser.Model.MediaInfo;
  29. using MediaBrowser.Model.System;
  30. using MediaBrowser.Model.Updates;
  31. using MediaBrowser.Providers;
  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.Persistence;
  41. using MediaBrowser.Server.Implementations.Providers;
  42. using MediaBrowser.Server.Implementations.ServerManager;
  43. using MediaBrowser.Server.Implementations.Session;
  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 media encoder.
  155. /// </summary>
  156. /// <value>The media encoder.</value>
  157. private IMediaEncoder MediaEncoder { get; set; }
  158. private ILocalizationManager LocalizationManager { get; set; }
  159. /// <summary>
  160. /// Gets or sets the user data repository.
  161. /// </summary>
  162. /// <value>The user data repository.</value>
  163. private IUserDataRepository UserDataRepository { get; set; }
  164. private IUserRepository UserRepository { get; set; }
  165. internal IDisplayPreferencesRepository DisplayPreferencesRepository { get; set; }
  166. private IItemRepository ItemRepository { get; set; }
  167. /// <summary>
  168. /// The full path to our startmenu shortcut
  169. /// </summary>
  170. protected override string ProductShortcutPath
  171. {
  172. get { return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.StartMenu), "Media Browser 3", "Media Browser Server.lnk"); }
  173. }
  174. private Task<IHttpServer> _httpServerCreationTask;
  175. /// <summary>
  176. /// Runs the startup tasks.
  177. /// </summary>
  178. /// <returns>Task.</returns>
  179. public override async Task RunStartupTasks()
  180. {
  181. await base.RunStartupTasks().ConfigureAwait(false);
  182. DirectoryWatchers.Start();
  183. Logger.Info("Core startup complete");
  184. Parallel.ForEach(GetExports<IServerEntryPoint>(), entryPoint =>
  185. {
  186. try
  187. {
  188. entryPoint.Run();
  189. }
  190. catch (Exception ex)
  191. {
  192. Logger.ErrorException("Error in {0}", ex, entryPoint.GetType().Name);
  193. }
  194. });
  195. }
  196. /// <summary>
  197. /// Called when [logger loaded].
  198. /// </summary>
  199. protected override void OnLoggerLoaded()
  200. {
  201. base.OnLoggerLoaded();
  202. _httpServerCreationTask = Task.Run(() => ServerFactory.CreateServer(this, LogManager, "Media Browser", "dashboard/index.html"));
  203. }
  204. /// <summary>
  205. /// Registers resources that classes will depend on
  206. /// </summary>
  207. /// <returns>Task.</returns>
  208. protected override async Task RegisterResources()
  209. {
  210. ServerKernel = new Kernel();
  211. await base.RegisterResources().ConfigureAwait(false);
  212. RegisterSingleInstance<IHttpResultFactory>(new HttpResultFactory(LogManager));
  213. RegisterSingleInstance<IServerApplicationHost>(this);
  214. RegisterSingleInstance<IServerApplicationPaths>(ApplicationPaths);
  215. RegisterSingleInstance(ServerKernel);
  216. RegisterSingleInstance(ServerConfigurationManager);
  217. RegisterSingleInstance<IWebSocketServer>(() => new AlchemyServer(Logger));
  218. RegisterSingleInstance<IIsoManager>(() => new PismoIsoManager(Logger));
  219. RegisterSingleInstance<IBlurayExaminer>(() => new BdInfoExaminer());
  220. ZipClient = new DotNetZipClient();
  221. RegisterSingleInstance(ZipClient);
  222. UserDataRepository = new SqliteUserDataRepository(ApplicationPaths, JsonSerializer, LogManager);
  223. RegisterSingleInstance(UserDataRepository);
  224. UserRepository = new SqliteUserRepository(ApplicationPaths, JsonSerializer, LogManager);
  225. RegisterSingleInstance(UserRepository);
  226. DisplayPreferencesRepository = new SqliteDisplayPreferencesRepository(ApplicationPaths, JsonSerializer, LogManager);
  227. RegisterSingleInstance(DisplayPreferencesRepository);
  228. ItemRepository = new SqliteItemRepository(ApplicationPaths, JsonSerializer, LogManager);
  229. RegisterSingleInstance(ItemRepository);
  230. UserManager = new UserManager(Logger, ServerConfigurationManager);
  231. RegisterSingleInstance(UserManager);
  232. LibraryManager = new LibraryManager(Logger, TaskManager, UserManager, ServerConfigurationManager, UserDataRepository, () => DirectoryWatchers);
  233. RegisterSingleInstance(LibraryManager);
  234. InstallationManager = new InstallationManager(HttpClient, PackageManager, JsonSerializer, Logger, this);
  235. RegisterSingleInstance(InstallationManager);
  236. DirectoryWatchers = new DirectoryWatchers(LogManager, TaskManager, LibraryManager, ServerConfigurationManager);
  237. RegisterSingleInstance(DirectoryWatchers);
  238. ProviderManager = new ProviderManager(HttpClient, ServerConfigurationManager, DirectoryWatchers, LogManager, LibraryManager);
  239. RegisterSingleInstance(ProviderManager);
  240. RegisterSingleInstance<ILibrarySearchEngine>(() => new LuceneSearchEngine(ApplicationPaths, LogManager, LibraryManager));
  241. MediaEncoder = new MediaEncoder(LogManager.GetLogger("MediaEncoder"), ZipClient, ApplicationPaths, JsonSerializer);
  242. RegisterSingleInstance(MediaEncoder);
  243. var clientConnectionManager = new SessionManager(UserDataRepository, ServerConfigurationManager, Logger, UserRepository);
  244. RegisterSingleInstance<ISessionManager>(clientConnectionManager);
  245. HttpServer = await _httpServerCreationTask.ConfigureAwait(false);
  246. RegisterSingleInstance(HttpServer, false);
  247. ServerManager = new ServerManager(this, JsonSerializer, Logger, ServerConfigurationManager);
  248. RegisterSingleInstance(ServerManager);
  249. LocalizationManager = new LocalizationManager(ServerConfigurationManager);
  250. RegisterSingleInstance(LocalizationManager);
  251. var displayPreferencesTask = Task.Run(async () => await ConfigureDisplayPreferencesRepositories().ConfigureAwait(false));
  252. var itemsTask = Task.Run(async () => await ConfigureItemRepositories().ConfigureAwait(false));
  253. var userdataTask = Task.Run(async () => await ConfigureUserDataRepositories().ConfigureAwait(false));
  254. var userTask = Task.Run(async () => await ConfigureUserRepositories().ConfigureAwait(false));
  255. await Task.WhenAll(itemsTask, userTask, displayPreferencesTask, userdataTask).ConfigureAwait(false);
  256. SetKernelProperties();
  257. }
  258. /// <summary>
  259. /// Sets the kernel properties.
  260. /// </summary>
  261. private void SetKernelProperties()
  262. {
  263. ServerKernel.ImageManager = new ImageManager(LogManager.GetLogger("ImageManager"),
  264. ApplicationPaths, ItemRepository);
  265. Parallel.Invoke(
  266. () => ServerKernel.FFMpegManager = new FFMpegManager(ApplicationPaths, MediaEncoder, LibraryManager, Logger, ItemRepository),
  267. () => ServerKernel.ImageManager.ImageEnhancers = GetExports<IImageEnhancer>().OrderBy(e => e.Priority).ToArray(),
  268. () => LocalizedStrings.StringFiles = GetExports<LocalizedStringData>(),
  269. SetStaticProperties
  270. );
  271. }
  272. /// <summary>
  273. /// Configures the repositories.
  274. /// </summary>
  275. /// <returns>Task.</returns>
  276. private async Task ConfigureDisplayPreferencesRepositories()
  277. {
  278. await DisplayPreferencesRepository.Initialize().ConfigureAwait(false);
  279. }
  280. /// <summary>
  281. /// Configures the item repositories.
  282. /// </summary>
  283. /// <returns>Task.</returns>
  284. private async Task ConfigureItemRepositories()
  285. {
  286. await ItemRepository.Initialize().ConfigureAwait(false);
  287. ((LibraryManager)LibraryManager).ItemRepository = ItemRepository;
  288. }
  289. /// <summary>
  290. /// Configures the user data repositories.
  291. /// </summary>
  292. /// <returns>Task.</returns>
  293. private Task ConfigureUserDataRepositories()
  294. {
  295. return UserDataRepository.Initialize();
  296. }
  297. /// <summary>
  298. /// Configures the user repositories.
  299. /// </summary>
  300. /// <returns>Task.</returns>
  301. private async Task ConfigureUserRepositories()
  302. {
  303. await UserRepository.Initialize().ConfigureAwait(false);
  304. ((UserManager)UserManager).UserRepository = UserRepository;
  305. }
  306. /// <summary>
  307. /// Dirty hacks
  308. /// </summary>
  309. private void SetStaticProperties()
  310. {
  311. // For now there's no real way to inject these properly
  312. BaseItem.Logger = LogManager.GetLogger("BaseItem");
  313. BaseItem.ConfigurationManager = ServerConfigurationManager;
  314. BaseItem.LibraryManager = LibraryManager;
  315. BaseItem.ProviderManager = ProviderManager;
  316. BaseItem.LocalizationManager = LocalizationManager;
  317. BaseItem.ItemRepository = ItemRepository;
  318. User.XmlSerializer = XmlSerializer;
  319. User.UserManager = UserManager;
  320. LocalizedStrings.ApplicationPaths = ApplicationPaths;
  321. }
  322. /// <summary>
  323. /// Finds the parts.
  324. /// </summary>
  325. protected override void FindParts()
  326. {
  327. if (IsFirstRun)
  328. {
  329. RegisterServerWithAdministratorAccess();
  330. }
  331. base.FindParts();
  332. HttpServer.Init(GetExports<IRestfulService>(false));
  333. ServerManager.AddWebSocketListeners(GetExports<IWebSocketListener>(false));
  334. StartServer(true);
  335. LibraryManager.AddParts(GetExports<IResolverIgnoreRule>(),
  336. GetExports<IVirtualFolderCreator>(),
  337. GetExports<IItemResolver>(),
  338. GetExports<IIntroProvider>(),
  339. GetExports<IBaseItemComparer>(),
  340. GetExports<ILibraryPrescanTask>(),
  341. GetExports<ILibraryPostScanTask>(),
  342. GetExports<IMetadataSaver>());
  343. ProviderManager.AddParts(GetExports<BaseMetadataProvider>().ToArray());
  344. }
  345. /// <summary>
  346. /// Starts the server.
  347. /// </summary>
  348. /// <param name="retryOnFailure">if set to <c>true</c> [retry on failure].</param>
  349. private void StartServer(bool retryOnFailure)
  350. {
  351. try
  352. {
  353. ServerManager.Start();
  354. }
  355. catch
  356. {
  357. if (retryOnFailure)
  358. {
  359. RegisterServerWithAdministratorAccess();
  360. StartServer(false);
  361. }
  362. else
  363. {
  364. throw;
  365. }
  366. }
  367. }
  368. /// <summary>
  369. /// Called when [configuration updated].
  370. /// </summary>
  371. /// <param name="sender">The sender.</param>
  372. /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  373. protected override void OnConfigurationUpdated(object sender, EventArgs e)
  374. {
  375. base.OnConfigurationUpdated(sender, e);
  376. if (!string.Equals(HttpServer.UrlPrefix, HttpServerUrlPrefix, StringComparison.OrdinalIgnoreCase))
  377. {
  378. NotifyPendingRestart();
  379. }
  380. else if (!ServerManager.SupportsNativeWebSocket && ServerManager.WebSocketPortNumber != ServerConfigurationManager.Configuration.LegacyWebSocketPortNumber)
  381. {
  382. NotifyPendingRestart();
  383. }
  384. }
  385. /// <summary>
  386. /// Restarts this instance.
  387. /// </summary>
  388. public override void Restart()
  389. {
  390. App.Instance.Restart();
  391. }
  392. /// <summary>
  393. /// Gets or sets a value indicating whether this instance can self update.
  394. /// </summary>
  395. /// <value><c>true</c> if this instance can self update; otherwise, <c>false</c>.</value>
  396. public override bool CanSelfUpdate
  397. {
  398. get { return ConfigurationManager.CommonConfiguration.EnableAutoUpdate; }
  399. }
  400. /// <summary>
  401. /// Checks for update.
  402. /// </summary>
  403. /// <param name="cancellationToken">The cancellation token.</param>
  404. /// <param name="progress">The progress.</param>
  405. /// <returns>Task{CheckForUpdateResult}.</returns>
  406. public async override Task<CheckForUpdateResult> CheckForApplicationUpdate(CancellationToken cancellationToken, IProgress<double> progress)
  407. {
  408. var availablePackages = await PackageManager.GetAvailablePackagesStatic(CancellationToken.None).ConfigureAwait(false);
  409. var version = InstallationManager.GetLatestCompatibleVersion(availablePackages, Constants.MbServerPkgName, ConfigurationManager.CommonConfiguration.SystemUpdateLevel);
  410. return version != null ? new CheckForUpdateResult { AvailableVersion = version.version, IsUpdateAvailable = version.version > ApplicationVersion, Package = version } :
  411. new CheckForUpdateResult { AvailableVersion = ApplicationVersion, IsUpdateAvailable = false };
  412. }
  413. /// <summary>
  414. /// Gets the composable part assemblies.
  415. /// </summary>
  416. /// <returns>IEnumerable{Assembly}.</returns>
  417. protected override IEnumerable<Assembly> GetComposablePartAssemblies()
  418. {
  419. // Gets all plugin assemblies by first reading all bytes of the .dll and calling Assembly.Load against that
  420. // This will prevent the .dll file from getting locked, and allow us to replace it when needed
  421. foreach (var pluginAssembly in Directory
  422. .EnumerateFiles(ApplicationPaths.PluginsPath, "*.dll", SearchOption.TopDirectoryOnly)
  423. .Select(LoadAssembly).Where(a => a != null))
  424. {
  425. yield return pluginAssembly;
  426. }
  427. // Include composable parts in the Api assembly
  428. yield return typeof(ApiEntryPoint).Assembly;
  429. // Include composable parts in the Dashboard assembly
  430. yield return typeof(DashboardInfo).Assembly;
  431. // Include composable parts in the Model assembly
  432. yield return typeof(SystemInfo).Assembly;
  433. // Include composable parts in the Common assembly
  434. yield return typeof(IApplicationHost).Assembly;
  435. // Include composable parts in the Controller assembly
  436. yield return typeof(Kernel).Assembly;
  437. // Include composable parts in the Providers assembly
  438. yield return typeof(ImagesByNameProvider).Assembly;
  439. // Common implementations
  440. yield return typeof(TaskManager).Assembly;
  441. // Server implementations
  442. yield return typeof(ServerApplicationPaths).Assembly;
  443. // Include composable parts in the running assembly
  444. yield return GetType().Assembly;
  445. }
  446. private readonly string _systemId = Environment.MachineName.GetMD5().ToString();
  447. /// <summary>
  448. /// Gets the system status.
  449. /// </summary>
  450. /// <returns>SystemInfo.</returns>
  451. public virtual SystemInfo GetSystemInfo()
  452. {
  453. return new SystemInfo
  454. {
  455. HasPendingRestart = HasPendingRestart,
  456. Version = ApplicationVersion.ToString(),
  457. IsNetworkDeployed = CanSelfUpdate,
  458. WebSocketPortNumber = ServerManager.WebSocketPortNumber,
  459. SupportsNativeWebSocket = ServerManager.SupportsNativeWebSocket,
  460. FailedPluginAssemblies = FailedAssemblies.ToArray(),
  461. InProgressInstallations = InstallationManager.CurrentInstallations.Select(i => i.Item1).ToArray(),
  462. CompletedInstallations = InstallationManager.CompletedInstallations.ToArray(),
  463. Id = _systemId,
  464. ProgramDataPath = ApplicationPaths.ProgramDataPath
  465. };
  466. }
  467. /// <summary>
  468. /// Shuts down.
  469. /// </summary>
  470. public override void Shutdown()
  471. {
  472. App.Instance.Dispatcher.Invoke(App.Instance.Shutdown);
  473. }
  474. /// <summary>
  475. /// Registers the server with administrator access.
  476. /// </summary>
  477. private void RegisterServerWithAdministratorAccess()
  478. {
  479. Logger.Info("Requesting administrative access to authorize http server");
  480. // Create a temp file path to extract the bat file to
  481. var tmpFile = Path.Combine(ConfigurationManager.CommonApplicationPaths.TempDirectory, Guid.NewGuid() + ".bat");
  482. // Extract the bat file
  483. using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("MediaBrowser.ServerApplication.RegisterServer.bat"))
  484. {
  485. using (var fileStream = File.Create(tmpFile))
  486. {
  487. stream.CopyTo(fileStream);
  488. }
  489. }
  490. var startInfo = new ProcessStartInfo
  491. {
  492. FileName = tmpFile,
  493. Arguments = string.Format("{0} {1} {2} {3}", ServerConfigurationManager.Configuration.HttpServerPortNumber,
  494. HttpServerUrlPrefix,
  495. UdpServerPort,
  496. ServerConfigurationManager.Configuration.LegacyWebSocketPortNumber),
  497. CreateNoWindow = true,
  498. WindowStyle = ProcessWindowStyle.Hidden,
  499. Verb = "runas",
  500. ErrorDialog = false
  501. };
  502. using (var process = Process.Start(startInfo))
  503. {
  504. process.WaitForExit();
  505. }
  506. }
  507. }
  508. }