shortcut command line

Most Windows users create shortcuts by right-clicking, dragging, or using the GUI shortcut wizard. For IT professionals, however, manual shortcut creation doesn’t scale.

In real-world environments, creating shortcuts from the command line becomes essential when you need to:

  • Deploy shortcuts to hundreds or thousands of endpoints
  • Package shortcuts into login scripts, task sequences, or installers
  • Work on Server Core or restricted environments
  • Create consistent, repeatable desktop layouts
  • Avoid user error and manual configuration drift

This article walks through modern, supported methods for creating Windows shortcuts programmatically, with a strong focus on PowerShell-first approaches, enterprise deployment, and browser-specific shortcuts.


Understanding Windows Shortcut Types

Before diving into commands, it’s important to understand that Windows uses multiple shortcut formats:

TypeExtensionUse Case
File/Program Shortcut.lnkApps, scripts, executables
Internet Shortcut.urlWeb pages
Pinned / App Links.lnkTaskbar / Start Menu
Legacy Website Shortcut.websiteIE-only (deprecated)

For most IT automation scenarios, you’ll be working with .lnk and .url files.


The Legacy shortcut.exe Tool (Why You Should Avoid It)

Older guides often reference a utility called shortcut.exe, a small third-party binary that can create .lnk files from the command line.

While it works, it is not recommended today for several reasons:

  • Not built into Windows
  • Often flagged by endpoint protection
  • Not digitally signed
  • Poor support and documentation
  • Difficult to justify in enterprise security reviews

IT Opinion

If you’re managing modern Windows environments, PowerShell or native Windows Script Host (WSH) APIs are the correct tools.

How to create a shortcut from the command line

Shortcut

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=https://supertechman.com.au/ >> 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:https://supertechman.com.au

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” https://supertechman.com.au

The Modern, Supported Way: PowerShell (Recommended)

PowerShell uses the Windows Script Host (WScript.Shell) COM object, which is fully supported and available on every supported Windows version.

Basic PowerShell Shortcut Creation

$WshShell = New-Object -ComObject WScript.Shell
$Shortcut = $WshShell.CreateShortcut("$env:Public\Desktop\Calculator.lnk")
$Shortcut.TargetPath = "C:\Windows\System32\calc.exe"
$Shortcut.Save()

This creates a shortcut on the Public Desktop, making it visible to all users.


Adding Advanced Shortcut Properties

One of the biggest advantages of PowerShell is control.

Example: Shortcut with Icon, Working Directory, and Arguments

$WshShell = New-Object -ComObject WScript.Shell
$Shortcut = $WshShell.CreateShortcut("$env:Public\Desktop\App.lnk")
$Shortcut.TargetPath = "C:\Program Files\App\App.exe"
$Shortcut.Arguments = "--silent"
$Shortcut.WorkingDirectory = "C:\Program Files\App"
$Shortcut.IconLocation = "C:\Program Files\App\App.ico,0"
$Shortcut.WindowStyle = 1
$Shortcut.Description = "Corporate Application"
$Shortcut.Save()

Real-World Use Case

This approach is ideal for:

  • MSI post-install scripts
  • Intune remediation scripts
  • SCCM/MECM deployments
  • Citrix / RDS profile customisation

Creating Shortcuts for All Users vs Current User

All Users Desktop

$env:Public\Desktop

Current User Desktop

[Environment]::GetFolderPath("Desktop")

IT Best Practice

Use Public Desktop sparingly. Too many shortcuts create clutter and user frustration.


Creating Internet (URL) Shortcuts from the Command Line

Internet shortcuts are simple text files with a .url extension.

PowerShell URL Shortcut Example

$path = "$env:Public\Desktop\Company Portal.url"
@"
[InternetShortcut]
URL=https://portal.company.com
"@ | Out-File -Encoding ASCII $path

This method is:

  • Lightweight
  • Browser-agnostic
  • Easy to audit

Browser-Specific Shortcuts (Edge, Chrome, Legacy IE)

Microsoft Edge Shortcut

$WshShell = New-Object -ComObject WScript.Shell
$Shortcut = $WshShell.CreateShortcut("$env:Public\Desktop\Edge Portal.lnk")
$Shortcut.TargetPath = "$env:windir\explorer.exe"
$Shortcut.Arguments = "microsoft-edge:https://supertechman.com.au"
$Shortcut.Save()

Google Chrome Shortcut

$Shortcut.TargetPath = "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"
$Shortcut.Arguments = "https://supertechman.com.au"

IT Insight

Chrome installs to Program Files (x86) even on 64-bit systems — a common scripting mistake.


Legacy Internet Explorer Pinned Sites (Not Recommended)

IE .website pinned shortcuts were designed to force IE usage.

While they still exist on legacy systems:

  • Internet Explorer is end-of-life
  • Edge IE Mode is the supported alternative
  • New .website shortcuts should not be created

Recommendation

If you need legacy compatibility, create an Edge shortcut using IE Mode policies, not .website files.


Using NirCmd for Shortcut Creation

NirCmd is a powerful third-party command-line tool that can create shortcuts and perform system tasks.

Example NirCmd Shortcut Command

nircmd.exe shortcut "C:\Windows\System32\calc.exe" "%Public%\Desktop" "Calculator"

Pros

  • Simple syntax
  • Single binary
  • Supports many system actions

Cons

  • Third-party tool
  • Security teams often block it
  • Requires justification in enterprise environments

IT Verdict

Useful for personal admin kits, but PowerShell is safer for production deployments.


Automating Shortcut Creation at Scale

Common Deployment Scenarios

  • User logon scripts
  • Intune proactive remediations
  • SCCM task sequences
  • RDS profile initialisation
  • VDI non-persistent desktops

Pro Tip

Always make scripts idempotent — check if the shortcut already exists before creating it.

if (-not (Test-Path $ShortcutPath)) {
    # Create shortcut
}

Security and Maintenance Considerations

  • Avoid hardcoding paths when possible
  • Use environment variables
  • Document why shortcuts are created
  • Remove deprecated shortcuts over time
  • Don’t overpopulate desktops

A cluttered desktop is often interpreted by users as a “broken system”.


Final Thoughts from the Field

Creating desktop shortcuts from the command line isn’t about being clever — it’s about control, consistency, and scale.

In modern Windows environments:

  • PowerShell is the gold standard
  • Native APIs beat third-party tools
  • Automation reduces support overhead
  • Clean desktops improve user experience

If you’re still relying on manual shortcut creation, you’re wasting time — and introducing inconsistency.

Leave a Reply

Your email address will not be published. Required fields are marked *