引用 IWshRuntimeLibrary;
引用COM组件:Windows Script Host Object Model
#region 创建桌面快捷方式
string exePath = "D:\\ceshi\\demo01.exe";
// 获取当前可执行文件的路径
string executablePath = Assembly.GetExecutingAssembly().Location;
// 获取桌面路径
string desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
// 创建快捷方式文件的路径
string shortcutPath = System.IO.Path.Combine(desktopPath, "GXYLaundry.lnk");
// 创建 WshShell 对象
WshShell shell = new WshShell();
// 创建快捷方式
IWshShortcut shortcut = (IWshShortcut)shell.CreateShortcut(shortcutPath);
// 设置快捷方式属性
shortcut.TargetPath = xiyi_exe;
shortcut.WorkingDirectory = System.IO.Path.GetDirectoryName(xiyi_exe);
shortcut.Description = "快捷键";
shortcut.IconLocation = xiyi_exe; // 使用应用程序图标
// 保存快捷方式
shortcut.Save();
#endregion