Create File or Folder Shortcuts from Command Line in Windows

Print View Mobile View

It is extremely easy to create shortcut to a file or folder using the Shortcut Create wizard in Windows, but there’s no direct way to create a shortcut from the command line. Sure, there is the mklink utility but it creates a “symbolic link” and not a “shortcut”.

If you want to create shortcuts from command-line in Windows, here are some ways:

Windows PowerShell

Save below script in a file named set-shortcut.ps1. Then place it inside your $pwd (Program Working Directory). If you don’t know the path, simply entering $pwd in PowerShell will give you the location. The default path is C:\Windows\System32.

param ( [string]$SourceExe, [string]$DestinationPath )
$WshShell = New-Object -comObject WScript.Shell
$Shortcut = $WshShell.CreateShortcut($SourceExe)
$Shortcut.TargetPath = $DestinationPath

Now whenever you want to create a shortcut from PowerShell, call it like this:

Set-ShortCut "C:\Path\to\Save\Shortcut.lnk" "C:\Path\To\Program.exe"

Download: set-shortcut


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 :

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.

Download: Shortcut


NirCmd is a command-line utility from Nir Sofer that can create shortcut to a file or folder, among various other tasks.

Its syntax is:

nircmd.exe shortcut [Target file/folder] [Destination folder] [Filename]

Download: NirCmd

With these methods, you can also create shortcut to a file, folder, or network path that doesn’t exist or is unavailable at the moment.