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")); }
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); }