I am creating startup entry in window startup. If user deselects the entry using msconfig startup window, my app creates a duplicate entry. I need to either remove the existing entry if it existing there or skip creating duplicate. How can I do that?
My code to create startup entry is this:-
string startUpFolderPath = Environment.GetFolderPath(Environment.SpecialFolder.Startup) + "\\" + "MyexeName.exe";
if (System.IO.File.Exists(startUpFolderPath))
{
return;
}
WshShellClass wshShell = new WshShellClass();
IWshRuntimeLibrary.IWshShortcut shortcut;
shortcut = (IWshRuntimeLibrary.IWshShortcut)wshShell.CreateShortcut(startUpFolderPath);
shortcut.TargetPath = Application.ExecutablePath;
shortcut.WorkingDirectory = Application.StartupPath;
shortcut.Save();