SHORTCUT.exe – Windows CMD Command
Notice: A non well formed numeric value encountered in /home/future4tech/public_html/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php on line 118
Notice: A non well formed numeric value encountered in /home/future4tech/public_html/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php on line 119
Notice: A non well formed numeric value encountered in /home/future4tech/public_html/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php on line 118
Notice: A non well formed numeric value encountered in /home/future4tech/public_html/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php on line 119
Notice: A non well formed numeric value encountered in /home/future4tech/public_html/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php on line 118
Notice: A non well formed numeric value encountered in /home/future4tech/public_html/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php on line 119
Notice: A non well formed numeric value encountered in /home/future4tech/public_html/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php on line 118
Notice: A non well formed numeric value encountered in /home/future4tech/public_html/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php on line 119
Create a windows shortcut (.LNK file)
This utility works under Windows 7 but fails under Windows 10. A good alternative is shortcut.exe from Optimum X.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
Syntax SHORTCUT [options] Key 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.
Example
1 2 3 |
@ECHO off MD %userprofile%"\start menu\programs\MY APP" SHORTCUT -f -t C:\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\myshortcut.vbs
Optional sections in the VBscript below are commented out:
1 2 3 4 5 6 7 8 9 10 11 12 |
Set oWS = WScript.CreateObject("WScript.Shell") sLinkFile = "C:\MyShortcut.LNK" Set oLink = oWS.CreateShortcut(sLinkFile) oLink.TargetPath = "C:\Program Files\MyApp\MyProgram.EXE" ' oLink.Arguments = "" ' oLink.Description = "MyProgram" ' oLink.HotKey = "ALT+CTRL+F" ' oLink.IconLocation = "C:\Program Files\MyApp\MyProgram.EXE, 2" ' oLink.WindowStyle = "1" ' oLink.WorkingDirectory = "C:\Program Files\MyApp" oLink.Save |
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:
HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer
NoResolveTrack
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):
HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer
“LinkResolveIgnoreLinkInfo”=1
Internet Shortcuts
Unlike file/folder shortcuts, Internet Explorer Favourite (.URL) files are simple text files which you can create with a text editor or a couple of ECHO statements:
1 |
Echo [InternetShortcut] > demo.url |
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.