Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Edit shortcuts .lnk properties with C#

0.00/5 (No votes)
23 Nov 2009 1  
This trick will allow you to edit shortcut properties in Windows.Add Windows Script Host Object Model reference under the COM tab. To do that, right click on References in Solution Explorer and then Add Reference. Insert the using statement: using IWshRuntimeLibrary; Here is the sample

This trick will allow you to edit shortcut properties in Windows.

  1. Add Windows Script Host Object Model reference under the COM tab. To do that, right click on References in Solution Explorer and then Add Reference.
  2. Insert the using statement: using IWshRuntimeLibrary;
  3. Here is the sample code
C#
WshShell shell = new WshShell();

IWshShortcut link = (IWshShortcut)shell.CreateShortcut(filename);

Now you can set and get various shortcut properties via methods in the link object.  Be sure to call the Save() to save changes you made.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here