Esempio n. 1
0
        public static void CreateStartupShortcut()
        {
            var link = new ShellLink {
                Target = Assembly.GetExecutingAssembly().Location
            };

            link.Save(Path.Combine(
                          Environment.GetFolderPath(Environment.SpecialFolder.Startup),
                          Path.GetFileNameWithoutExtension(link.Target) + ".lnk"));
        }
Esempio n. 2
0
        private static string _GetShortcutLocation(string folder)
        {
            var exePath = Assembly.GetExecutingAssembly().Location;

            foreach (var file in Directory.GetFiles(folder))
            {
                if (file.EndsWith("lnk") == false)
                {
                    continue;
                }

                var link = new ShellLink(file);
                if (link.Target == exePath)
                {
                    return(link.ShortCutFile);
                }
            }

            return(string.Empty);
        }