Creating a file shortcut (.lnk)

One way to do this is pointed out by Joepro in their answer here:

You’ll need to add a COM reference to Windows Scripting Host. As far as i know, there is no native .net way to do this.

WshShellClass wsh = new WshShellClass();
IWshRuntimeLibrary.IWshShortcut shortcut = wsh.CreateShortcut(
    Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\shorcut.lnk") as IWshRuntimeLibrary.IWshShortcut;
shortcut.Arguments = "";
shortcut.TargetPath = "c:\\app\\myftp.exe";
// not sure about what this is for
shortcut.WindowStyle = 1; 
shortcut.Description = "my shortcut description";
shortcut.WorkingDirectory = "c:\\app";
shortcut.IconLocation = "specify icon location";
shortcut.Save();

For .Net 4.0 and above, replace the first line with the following:

 WshShell wsh = new WshShell();

EDIT:
This link can help too

Leave a Comment