我正在窗口启动中创建启动条目。如果用户使用 msconfig 启动窗口取消选择该条目,我的应用程序会创建一个重复的条目。如果现有条目存在,我需要删除它或跳过创建重复项。我怎样才能做到这一点?
我创建启动条目的代码是这样的:-
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();