Create a windows shortcut (.LNK file) Originally in the NT4 Server Resource Kit, this utility fails under Windows 10.
A good free alternative is shortcut.exe from [ mirror]. See other alternatives below.

      SHORTCUT [options]

   Source options

   -t target    : The path and file name of the application/document to open.
   -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 simple (don’t use LinkResolve)

   Export options

   -u [spec]    : ECHO the contents of an existing shortcut. 
                  'all' is the same as 'natdix' but the letters 
                  of 'natdix' 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.

Shortcut NTFS file system tracking

If a shortcut to a file breaks because the destination file has moved, then by default Windows will attempt to automatically locate the shortcut destination by performing a search or matching file properties. This can be turned on or off in the registry:


0 = disabled, 1 = enabled (REG_DWORD)

Shortcut Auto LinkResolve

By default shortcuts will include the destination machine, even for a target like C:\MyFile.doc
This is not immediately visible until the shortcut.LNK file is copied to another machine, the shortcut target will then be automatically updated to point back to \\Machine1\c$\MyFile.doc
To turn this behaviour off use shortcut.exe -s or add a DWORD value of 1 to the registry (before creating the shortcut):


Internet Shortcuts

Unlike file/folder shortcuts, Favourite (.URL) files are simple text files which you can create with a text editor or a couple of ECHO statements, they will open in the default browser:

Echo [InternetShortcut] > demo.url
Echo URL= >> demo.url

Edge Shortcuts

If Edge is not your default browser, but you want to open a web page using Edge, set the Shortcut Target to a path like the following:

%windir%\explorer.exe microsoft-edge:

Internet Explorer 11 Pinned sites

If you drag a URL/Icon from the address bar of IE 11 to the desktop, that will create an IE Pinned site (.website) link.

"Pinned sites" are designed specifically to only ever open in IE 11, you should use them for legacy systems containing Active-X controls or other cruft that won't work in Microsoft Edge.

Chrome Shortcuts

If Chrome is not your default browser, but you want to open a web page using Chrome, set the Shortcut Target to a path like the following, note that Chrome installs itself in the x86 folder even though it is a 64 bit application:

"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"


Create a shortcut to MyApp.exe

 SHORTCUT -f -t C:\demo\MyApp.exe -n %userprofile%"\start menu\programs\MY APP\MY APP"

An alternative is to use VBScript, call the VB script with cscript like so:
CSCRIPT C:\batch\makeshortcut.vbs

Optional sections in the VBscript below are commented out:

   Set objWS = WScript.CreateObject("WScript.Shell")
   strLinkFile = "C:\MyShortcut.LNK"
   Set objLink = objWS.CreateShortcut(strLinkFile)
   objLink.TargetPath = "C:\demo\MyApp.exe"
   '  objLink.Arguments = ""
   '  objLink.Description = "MyProgram"
   '  objLink.HotKey = "ALT+CTRL+F"
   '  objLink.IconLocation = "C:\Program Files\MyApp\MyProgram.EXE, 2"
   '  objLink.WindowStyle = "1"
   '  objLink.WorkingDirectory = "C:\Program Files\MyApp"

“The reasonable man adapts himself to the world: the unreasonable one persists in trying to adapt the world to himself. Therefore all progress depends on the unreasonable man” ~ George Bernard Shaw

Related commands:

Explorer.exe - Open Windows Explorer to show a directory, also accepts variables.
MD - Create folder(s)
FSUTIL - Create a Hardlink.
Pin a SHORTCUT to the start Menu (VBScript)
RUN commands - Start | Run commands.
Q158682 - Shortcuts resolve to a UNC Path (LinkResolveIgnoreLinkInfo)
Q150215 - Disable Automatic Shortcut Resolution.
Q254493 - Shortcut.exe fails with sub-folder names.
Q263324 - Shortcut.exe truncates long path names.
Q134552 - Shortcut key for shortcut only works when placed on Start Menu.
Equivalent bash command (Linux): symlink - Make a new name for a file, ln - Make links between files.

Copyright © 1999-2022
Some rights reserved