How to Create Desktop Shortcuts from Command Line

Most people will simply create a shortcut by using the shortcut wizard in Windows. But you can also create a shortcut from the command line. You may be asking yourself, Why would I want to create a shortcut from the command line??!! Well, in some cases you may want to automate the creation of a shortcut through a batch file to push out to users on a network or there may be an issue that is stopping you from using the wizard. If not for any reason at all, it might be just fun to do for something different.

If you want to create shortcuts from command-line in Windows, here’s how. –

How to create a shortcut from the command line


A shortcut is a small program, weighing just 56KB, that allows you to create, modify or query Windows shortcuts from the command line.

Its syntax is:

Shortcut.exe /F:filename /A:C|E|Q [/T:target] [/P:parameters] [/W:workingdir] [/R:runstyle] [/I:icon,index] [/H:hotkey] [/D:description]

For example, to create shortcut to Calculator in the current directory, the command would be as :h

shortcut.exe /F:Calculator.lnk /A:C /T:C:\Windows\System32\calc.exe

Shortcut lets you define custom icon for the shortcut, keyboard shortcut, define running mode, and more by adding additional parameters to the command. The complete list of supported parameters for the program is listed below.

Shortcut parameters:

/F:filename	: Specifies the .LNK shortcut file.
/A:action	: Defines the action to take (C=Create, E=Edit or Q=Query).
/T:target	: Defines the target path and file name the shortcut points to.
/P:parameters	: Defines the command-line parameters to pass to the target.
/W:working dir	: Defines the working directory the target starts with.
/R:run style	: Defines the window state (1=Normal, 3=Max, 7=Min).
/I:icon,index	: Defines the icon and optional index (file.exe or file.exe,0).
/H:hotkey	: Defines the hotkey, a numeric value of the keyboard shortcut.
/D:description	: Defines the description (or comment) for the shortcut.

Internet Shortcuts

Unlike file/folder shortcuts, Internet Explorer Favourite (.URL) files are simple text files that you can create with a text editor or a couple of ECHO statements:

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”