Code Simplified – Viral Sarvaiya

Code Simplified – Viral Sarvaiya, Web Developer Friends, dot net Developer, Sql Server Developer

Create shortcut of application programmatically

Posted by Viral Sarvaiya on December 28, 2010


Merry Christmas to all…

In my one of the application I get one new thing that I share here,

I m creating desktop icon  of one application from the already running application.

Here is the code…

For that you have add reference of “IWshRuntimeLibrary”

using IWshRuntimeLibrary;

and then call below function to the click event of the button from where u want to create the desktop icon.

private static void CreateShortcutOfApplication()
 // Create a new instance of WshShellClass
 WshShell = new WshShellClass();

 // Create the shortcut
 IWshRuntimeLibrary.IWshShortcut MyShortcut;

 //Get Path of Desktop Folder of Current User
 string path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);

 // Choose the path for the shortcut and name of the shortcut
 MyShortcut = (IWshRuntimeLibrary.IWshShortcut)WshShell.CreateShortcut(path + @"\ShortcutName.lnk");

 // Where the shortcut should point to
 MyShortcut.TargetPath = Application.StartupPath + "\\ApplicationName.exe";

 //Set Working Directory of Shortcut
 MyShortcut.WorkingDirectory = Application.StartupPath;

 // Description for the shortcut
 MyShortcut.Description = "Description of the Application";

 // Location for the shortcut's icon
 MyShortcut.IconLocation = Application.StartupPath + @"\Application.exe";

 // Create the shortcut at the given path

And when you click on this button then you get the icon of that application in desktop.

Hope this will helpful to you…


One Response to “Create shortcut of application programmatically”

  1. Nice one viru…

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: