1, 项目中添加一个引用。Project > Add Reference > COM > Windows Script Host Object Model.
示例代码:
WshShell shell = new WshShell();
string desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
string shotcutName = "alex.lnk";
string shortcutAddress = Path.Combine(desktopPath, shotcutName);
IWshShortcut shortcut = (IWshShortcut)shell.CreateShortcut(shortcutAddress);
shortcut.Description = "New shortcut for a Notepad";
//shortcut.Hotkey = "Ctrl+Shift+N";
shortcut.TargetPath = Environment.GetFolderPath(Environment.SpecialFolder.System) + @"\notepad.exe";
shortcut.Save();