Creating Shortcuts on your Desktop

by Dec 9, 2010

PowerShell and .NET can do amazing things, but they are not good at creating shortcuts. However, you can create a shortcut on your Desktop in a matter of only a few lines by using COM objects instead:

$shell = New-Object -ComObject WScript.Shell
$desktop = [System.Environment]::GetFolderPath('Desktop')
$shortcut = $shell.CreateShortcut("$desktop\clickme.lnk")
$shortcut.TargetPath = "notepad.exe"
$shortcut.IconLocation = "shell32.dll,23"
$shortcut.Save()

Twitter This Tip!
ReTweet this Tip!