Create a windows shortcut (.LNK file)

SHORTCUT [options]

Source options
-t target : The path and file name of the application. -a arguments : The arguments passed when the shortcut is used. -d directory : The folder to start the application in.
-i iconfile : The file the icon is in.
-x index : The index into the icon file.

options for the shortcut file to be created

-n name : The path and file name (.LNK) of the shortcut file.

-c : Change existing shortcut.
-r : Resolve broken shortcut.
-f : Force overwrite of an existing short cut.

-s : Make shortcut non tracking (Stupid)
Export options
-u [spec] : ECHO the contents of an existing shortcut. &qt;&qt;all&qt;&qt; is the same as &qt;&qt;natdix&qt;&qt; but the letters
of &qt;&qt;natdix&qt;&qt; specify the options to be exported (the same option can be specified more than once e.g. -u natn)

-l logfile : save any error messages in the specified file
If shortcut.exe fails to create a new shortcut, it does NOT set an errorlevel.


@ECHO off
MD &qt;userprofile&qt;"start menuprogramsMY APP"
SHORTCUT -f -t C:MyApp.exe -n &qt;userprofile&qt;"start menuprogramsMY APPMY APP"Alternatively use WSH to create a shortcut:
optional sections in the VBscript below are commented out

Set oWS = WScript.CreateObject("WScript.Shell")

sLinkFile = "C:MyShortcut.LNK"

Set oLink = oWS.CreateShortcut(sLinkFile)

oLink.TargetPath = "C:Program FilesMyAppMyProgram.EXE"
&qt;&qt; oLink.Arguments = &qt;
&qt;&qt; oLink.Description = "MyProgram"
&qt;&qt; oLink.HotKey = "ALT+CTRL+F"
&qt;&qt; oLink.IconLocation = "C:Program FilesMyAppMyProgram.EXE, 2"
&qt;&qt; oLink.WindowStyle = "1"
&qt;&qt; oLink.WorkingDirectory = "C:Program FilesMyApp"
Resolve Shortcut Links

If a shortcut to a file breaks, then by default Windows will attempt to automatically locate the shortcut destination by performing a simple search. To change this default – edit the registry:

This can also be controlled at Group Policy level in: User ConfigAdmin TemplatesStart Menu & Taskbar.

If a shortcut .LNK file is copied to another machine, then by default the shortcut&qt;&qt;s target may be automatically updated – e.g. create a shortcut on Machine1 to C:AUTOEXEC.BAT when copied to Machine2 the shortcut will point back to \Machine1c$AUTOEXEC.BAT
To change this default – add this to the registry before creating the shortcut:


Often confused with shortcuts, Internet Explorer Favourite (.URL) files are simple text files which you can create with a few ECHO statements.