using IWshRuntimeLibrary; using System.IO; public static void CreateShortcut(string targetPath, string shortcutFile, string description, string arguments, string hotKey, string workingDirectory, string iconLocation) { if (String.IsNullOrEmpty(targetPath)) throw new ArgumentNullException("targetPath"); if (String.IsNullOrEmpty(shortcutFile)) throw new ArgumentNullException("shortcutFile"); WshShellClass wshShell = new WshShellClass(); IWshRuntimeLibrary.IWshShortcut shortcut = (IWshRuntimeLibrary.IWshShortcut)wshShell.CreateShortcut(shortcutFile); shortcut.TargetPath = targetPath; shortcut.Description = description; if (!String.IsNullOrEmpty(arguments)) shortcut.Arguments = arguments; if (!String.IsNullOrEmpty(hotKey)) shortcut.Hotkey = hotKey; if (!String.IsNullOrEmpty(workingDirectory)) shortcut.WorkingDirectory = workingDirectory; if (!String.IsNullOrEmpty(iconLocation)) shortcut.IconLocation = iconLocation; shortcut.Save(); }
CreateShortcut(C:\\abc.exe", Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\abc.lnk", null, null, null, null, null);
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)