public static void CreateShortcut(string title, string linkPath, string filePath, Hotkey hotkey = null) { var shellType = Type.GetTypeFromProgID("WScript.Shell"); dynamic shell = Activator.CreateInstance(shellType); var shortcut = shell.CreateShortcut(linkPath); if (hotkey != null) { shortcut.Hotkey = hotkey.Text; } shortcut.Description = title; shortcut.TargetPath = filePath; shortcut.Save(); Marshal.ReleaseComObject(shell); }
public static void CreateShortcut(string title, string linkPath, string filePath, Hotkey hotkey = null) { var shellType = Type.GetTypeFromProgID("WScript.Shell"); dynamic shell = Activator.CreateInstance(shellType); var shortcut = shell.CreateShortcut(linkPath); if (hotkey != null) { shortcut.Hotkey = hotkey.Text; } shortcut.Description = title; shortcut.TargetPath = filePath; shortcut.Save(); Marshal.ReleaseComObject(shell); }