安装包创建桌面快捷方式


private void CreateDesktop() { string path = this.Context.Parameters["targetdir"]; path = path.Substring(0, path.LastIndexOf("/")); if (!System.IO.File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + "//" + "微信打印机.lnk")) { WshShell shell = new WshShell(); IWshShortcut shortcut = (IWshShortcut)shell.CreateShortcut( Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + "//" + "微信打印机.lnk" ); shortcut.TargetPath = System.Reflection.Assembly.GetExecutingAssembly().Location; shortcut.WorkingDirectory = System.Environment.CurrentDirectory; shortcut.WindowStyle = 1; //Normal window shortcut.Description = "微信打印机"; shortcut.IconLocation = path + "ico//desktop.ico"; shortcut.Save(); } }
原文地址:https://www.cnblogs.com/Iyce/p/4241082.html