检查启动文件夹是否已包含程序

本文关键字:包含 程序 是否 启动 文件夹 检查 | 更新日期: 2023-09-27 17:58:11

我基本上想检查当前程序是否已经链接到Windows启动文件夹,即使文件有其他名称或从其他目录运行。这可能吗,也许是通过检查程序的名称?

PS:我用这个代码把我的程序链接到启动文件夹:

using (ShellLink shortcut = new ShellLink()) {
    shortcut.Target = Application.ExecutablePath;
    shortcut.WorkingDirectory = Path.GetDirectoryName(Application.ExecutablePath);
    shortcut.Description = "My Shorcut Name Here";
    shortcut.DisplayMode = ShellLink.LinkDisplayMode.edmNormal;
    shortcut.Save(Environment.GetFolderPath(Environment.SpecialFolder.Startup));
}

谢谢。

检查启动文件夹是否已包含程序

您需要扫描启动的开始菜单文件夹,并为每个快捷方式比较目标路径和程序的路径。

WshShell shell = new WshShell(); 
var link = (IWshShortcut)shell.CreateShortcut(linkPathName); //Link the interface to our shortcut
var target = link.TargetPath;
//compare to your program's path...

尝试编写特洛伊木马程序=D

直截了当的解决方案:枚举Startup文件夹中的所有快捷方式(lnk文件),1乘1打开它们,然后查看(我假设您使用的是这种技术)。