Beispiel #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"));
        }
Beispiel #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.Equals(exePath, StringComparison.OrdinalIgnoreCase))
                {
                    return(link.ShortCutFile);
                }
            }

            return(string.Empty);
        }