jellyfin/MediaBrowser.ServerApplication/Native/Autorun.cs
2015-01-12 22:46:44 -05:00

36 lines
1.3 KiB
C#

using MediaBrowser.Common.IO;
using System;
using System.IO;
namespace MediaBrowser.ServerApplication.Native
{
/// <summary>
/// Class Autorun
/// </summary>
public static class Autorun
{
/// <summary>
/// Configures the specified autorun.
/// </summary>
/// <param name="autorun">if set to <c>true</c> [autorun].</param>
/// <param name="fileSystem">The file system.</param>
public static void Configure(bool autorun, IFileSystem fileSystem)
{
var shortcutPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.StartMenu), "Media Browser 3", "Media Browser Server.lnk");
var startupPath = Environment.GetFolderPath(Environment.SpecialFolder.Startup);
if (autorun)
{
//Copy our shortut into the startup folder for this user
File.Copy(shortcutPath, Path.Combine(startupPath, Path.GetFileName(shortcutPath) ?? "MBstartup.lnk"), true);
}
else
{
//Remove our shortcut from the startup folder for this user
fileSystem.DeleteFile(Path.Combine(startupPath, Path.GetFileName(shortcutPath) ?? "MBstartup.lnk"));
}
}
}
}