Sunday, December 19, 2010

C# Tutorial: Create Shortcuts for Applications [Start Menu]

Here is the code

using IWshRuntimeLibrary;
private void button1_Click(object sender, EventArgs e)
    WshShell shell = new WshShell();
    IWshShortcut MyShortcut;
    // Replace [UserName] with the name of the User
    MyShortcut = (IWshShortcut)shell.CreateShortcut(@"C:\Documents and Settings\[UserName]\Start Menu\Programs\MyShortcut.lnk");
    MyShortcut.TargetPath = Application.ExecutablePath;
    MyShortcut.Description = "Launch the App!";
    // MyShortcut.IconLocation = [IconPath]; // [IconPath] - the path of the icon for the shortcut, if you have one 


  1. Instate of [UserName] you can use [code]Environment.UserName[/code] ;)...

  2. The C# Shortcuts WinForms Control supports the modifier keys, multiple keys shortcuts, and Shortcuts without modifier keys to build a keyboard trigger action, such as Ctrl, Alt and Shift with any other keys to trigger a specific action for their Windows applications.

  3. Great! So if I want to put my shortcut inside of "My App" directory (e.g. ..\Start Menu\Programs\My App\myApp.exe), I should first create the directory? [Directory.CreateDirectory(@"...")]. Thanks!

  4. pathetic ... so what if you want create application for 10k users you need know all their usernames , and they must have desktop on C: ? unusefull