//获取桌面路径 string lnkPath = System.Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\" + "360安全浏览器比价版" + ".lnk"; //获取启动文件路径 string lnkPath1 = System.Environment.GetFolderPath(Environment.SpecialFolder.Startup) + "\\" + Application.ProductName + ".lnk"; IWshRuntimeLibrary.WshShell shell = new IWshRuntimeLibrary.WshShell(); IWshRuntimeLibrary.IWshShortcut shortCut = (IWshRuntimeLibrary.IWshShortcut)shell.CreateShortcut(lnkPath); shortCut.TargetPath = shortCut.TargetPath + "www.baidu.com"; shortCut.WindowStyle = shortCut.WindowStyle; shortCut.Description = shortCut.Description; shortCut.IconLocation = shortCut.IconLocation; shortCut.WorkingDirectory = shortCut.WorkingDirectory; shortCut.Save();
上面的代码修改完之后,快捷方式就不能用了。
shortCut.TargetPath = shortCut.TargetPath ;