C# 创建快捷方式

1、在项目中添加引用,Project > Add Reference > COM > Windows Script Host Object Model.

2、添加 using IWshRuntimeLibrary;

#region 创建快捷方式

WshShell wshShell = new WshShell();

string path = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory), "哈哈哈.lnk");

IWshShortcut shortcut = (IWshShortcut)wshShell.CreateShortcut(path);

shortcut.Description = "11111";

shortcut.TargetPath = Application.StartupPath + @"\OnlyRunOneEXE.exe";

shortcut.Save();

#endregion

posted @   龙骑科技  阅读(497)  评论(0编辑  收藏  举报
努力加载评论中...
点击右上角即可分享
微信分享提示