Click here to Skip to main content
16,008,750 members
Articles / Programming Languages / C#
Tip/Trick

Edit shortcuts .lnk properties with C#

Rate me:
Please Sign up or sign in to vote.
4.25/5 (7 votes)
23 Nov 2009CPOL 40.2K   10   2
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, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Junior)
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
QuestionI joined code project to say one thing. Pin
Member 141443998-Feb-19 6:30
Member 141443998-Feb-19 6:30 
This is one of the worst examples I have ever seen. How many times do you say you are giving an example of EDITING a shortcut. You only show how to create one, and NOT EVEN how to EDIT AFTER CREATING.

I don't understand how someone like you survives.
GeneralReason for my vote of 5 Spent some time Pin
Fastfootskater17-Jan-12 3:06
Fastfootskater17-Jan-12 3:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.