2
0

Autorun.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536
  1. using MediaBrowser.Common.IO;
  2. using System;
  3. using System.IO;
  4. using CommonIO;
  5. namespace MediaBrowser.ServerApplication.Native
  6. {
  7. /// <summary>
  8. /// Class Autorun
  9. /// </summary>
  10. public static class Autorun
  11. {
  12. /// <summary>
  13. /// Configures the specified autorun.
  14. /// </summary>
  15. /// <param name="autorun">if set to <c>true</c> [autorun].</param>
  16. /// <param name="fileSystem">The file system.</param>
  17. public static void Configure(bool autorun, IFileSystem fileSystem)
  18. {
  19. var shortcutPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.StartMenu), "Emby", "Emby Server.lnk");
  20. var startupPath = Environment.GetFolderPath(Environment.SpecialFolder.Startup);
  21. if (autorun)
  22. {
  23. //Copy our shortut into the startup folder for this user
  24. File.Copy(shortcutPath, Path.Combine(startupPath, Path.GetFileName(shortcutPath) ?? "Emby Server.lnk"), true);
  25. }
  26. else
  27. {
  28. //Remove our shortcut from the startup folder for this user
  29. fileSystem.DeleteFile(Path.Combine(startupPath, Path.GetFileName(shortcutPath) ?? "Emby Server.lnk"));
  30. }
  31. }
  32. }
  33. }