static string GetShortcutPath(ReflectedShell shell = null) { if (shell == null) { shell = new ReflectedShell(); } var startup = shell.GetSpecialFolder("Startup"); return Path.Combine(startup, "Caffeinated.lnk"); }
static string GetShortcutPath(ReflectedShell shell = null) { if (shell == null) { shell = new ReflectedShell(); } var startup = shell.GetSpecialFolder("Startup"); return(Path.Combine(startup, "Caffeinated.lnk")); }
private void StartupChkBox_CheckedChanged(object sender, EventArgs e) { var shell = new ReflectedShell(); var shortcut = GetShortcutPath(shell); var executable = Assembly.GetExecutingAssembly() .GetName().CodeBase; if (StartupChkBox.Checked) { // create shortcut in startup items folder in start menu shell.CreateShortcut(shortcut, executable); } else { // remove shortcut if it exists File.Delete(shortcut); } }