我已经在 C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup 中以编程方式创建了我的托盘应用程序的快捷方式。但是当我为任何用户登录时,我的托盘应用程序没有启动。它只是为管理员启动。有人可以告诉我,我花了整整一天的时间来解决这个问题,但无法解决它..
var startupFolderPath = Environment.GetFolderPath(Environment.SpecialFolder.CommonStartup);
var shell = new WshShell();
var shortCutLinkFilePath = string.Format("{0}\\{1}", startupFolderPath, "MyShortcut.lnk");
var windowsApplicationShortcut = (IWshShortcut)shell.CreateShortcut(shortCutLinkFilePath);
windowsApplicationShortcut.Description = "Shortcut for My Tray application.";
windowsApplicationShortcut.WorkingDirectory = assemblyPath;
windowsApplicationShortcut.TargetPath = executablePath;
windowsApplicationShortcut.Save();