When provisioning new Windows 11 machines, automating IT deployments, or standardising application environments, generating desktop and Start Menu shortcuts via graphical user interface wizards is tedious and inefficient. Windows PowerShell allows systems administrators and power users to script the creation of native .lnk shortcut files automatically using the COM-based Windows Script Host (WScript.Shell) interface.
Why Script Shortcut Creation with PowerShell?
Scripting desktop shortcuts provides complete programmatic control over application launcher parameters:
- Deployment Automation: Create standardized shortcuts silently during operating system provisioning, intune scripts, or user logon configurations.
- Custom Execution Arguments: Effortlessly append command-line arguments, switches, and config file flags to target executables (e.g., launching Chrome in Incognito mode or starting a Python script with specific parameters).
- Working Directory Control: Specify exact “Start In” working directories to prevent script path resolution failures.
- Custom Icon and Description Assignment: Define distinct icon indexes from
.icofiles or system DLLs (such asshell32.dllorimageres.dll) and assign accessible tooltip hover descriptions.
Step 1: Open Windows PowerShell
Launch PowerShell with standard or administrative permissions:
- Press Win + X and choose Terminal (or Windows PowerShell).
- If you intend to create shortcuts for all users system-wide in
C:\Users\Public\Desktop, launch Terminal as Administrator. For personal desktop shortcuts, standard user privileges are sufficient.
Step 2: Create a Basic Application Shortcut on the Desktop
To create a shortcut to an executable file on the current user’s desktop:
$WshShell = New-Object -ComObject WScript.Shell
$DesktopPath = [System.Environment]::GetFolderPath('Desktop')
$Shortcut = $WshShell.CreateShortcut("$DesktopPath\Notepad.lnk")
$Shortcut.TargetPath = "C:\Windows\notepad.exe"
$Shortcut.Description = "Launch Notepad Text Editor"
$Shortcut.Save()
Executing this block instantiates the COM object, resolves the user’s Desktop directory dynamically, creates the .lnk file pointer, assigns the target path, and calls .Save() to commit the file to disk instantly.
Step 3: Create an Advanced Shortcut with Arguments, Icons, and Hotkeys
For more complex configurations requiring custom runtime arguments, working directories, or keyboard combinations:
$WshShell = New-Object -ComObject WScript.Shell
$DesktopPath = [System.Environment]::GetFolderPath('Desktop')
# Define target shortcut path
$Shortcut = $WshShell.CreateShortcut("$DesktopPath\CustomChromeSession.lnk")
# Target executable and parameters
$Shortcut.TargetPath = "C:\Program Files\Google\Chrome\Application\chrome.exe"
$Shortcut.Arguments = "--incognito https://digitash.com"
$Shortcut.WorkingDirectory = "C:\Program Files\Google\Chrome\Application"
# Custom icon location (DLL path followed by icon index)
$Shortcut.IconLocation = "shell32.dll, 220"
# Assign a global launch hotkey (Ctrl + Alt + C)
$Shortcut.Hotkey = "Ctrl+Alt+C"
# Window style: 1 = Normal, 3 = Maximized, 7 = Minimized
$Shortcut.WindowStyle = 3
# Save the shortcut
$Shortcut.Save()
This script generates an enterprise-grade shortcut that automatically opens Google Chrome maximized in private mode with a custom system icon and an assigned global shortcut trigger.
Step 4: Create a Reusable PowerShell Function
To generate multiple shortcuts throughout your deployment scripts without repetitive boilerplate code, encapsulate the logic in a modular function:
function New-DesktopShortcut {
param (
[Parameter(Mandatory=$true)][string]$Name,
[Parameter(Mandatory=$true)][string]$TargetPath,
[string]$Arguments = "",
[string]$IconLocation = ""
)
$WshShell = New-Object -ComObject WScript.Shell
$DesktopPath = [System.Environment]::GetFolderPath('Desktop')
$Shortcut = $WshShell.CreateShortcut("$DesktopPath\$Name.lnk")
$Shortcut.TargetPath = $TargetPath
if ($Arguments) { $Shortcut.Arguments = $Arguments }
if ($IconLocation) { $Shortcut.IconLocation = $IconLocation }
$Shortcut.Save()
Write-Host "Shortcut created: $Name.lnk" -ForegroundColor Green
}
# Example usage:
New-DesktopShortcut -Name "Calculator" -TargetPath "calc.exe"
Incorporating PowerShell shortcut creation into your administration toolkit eliminates manual clicking and guarantees uniform application access across all managed Windows endpoints.