Autorun.cs 1.1 KB

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