aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.ServerApplication/Native/Autorun.cs
blob: 0262f711e7a3e2d6507f3145b1a2ea618133d83a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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>
        public static void Configure(bool autorun)
        {
            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
                File.Delete(Path.Combine(startupPath, Path.GetFileName(shortcutPath) ?? "MBstartup.lnk"));
            }
        }
    }
}