Brandon's Notepad

July 30, 2010

Programmatically Creating Windows Shortcuts

Filed under: Computer Software,How-To,Windows — Brandon @ 7:50 am
Tags: , , , , , ,

Home > My Lists > Technical Notes > Programmatically Creating Windows Shortcuts


Windows shortcut files can be created using a script. This is useful in circumstances when you need to distribute shortcuts across multiple computers, possible as part of a software installation procedure. The shortcuts themselves seem to be fairly portable, but this is a more pure way of controlling their content.


My Shell Example

I do a lot of work from the command line, so I take advantage of tried-and-true DOSKEY macros and other useful tools. I like to have these loaded for me whenever I open a new command prompt, so I maintain a shortcut that runs a batch file similar to the .login or .cshrc files used on Unix platforms prior to displaying the prompt. This is the pruned version of the script I use to maintain this shortcut definition:

Shell = new ActiveXObject(“WScript.Shell”);
link = Shell.CreateShortcut(“MyShell.lnk”);
link.TargetPath =”%SystemRoot%\\system32\\cmd.exe”;
link.Arguments = “/K %HOMEDRIVE%\dosrc.bat”;
link.WorkingDirectory = “%HOMEDRIVE%” + “%HOMEPATH%”;
link.IconLocation = “%SystemRoot%\\system32\\progman.exe,6”;
link.Description = “MyShell shortcut by B Brinkley”;

This is based on the example provided in the MSDN article linked above. The arguments are specific to cmd.exe, I rely heavily on environment variables for path info, and the icon is the long-standing MS-DOS logo with the interlocking letters.


Create a free website or blog at

%d bloggers like this: