Mostly we will simply copy an already created shortcut but With PowerShell you can create a shortcut by using the New-Object cmdlet. Let we look in to this detail below. Here’s a quick script to create a shortcut to Notepad and put it on the desktop.

Step #1: The First step is to define the location and name of your shortcut. The following example will add the shortcut to the user’s desktop with a name of Your Shortcut.

$SourceFileLocation = “$env:SystemRoot\System32\notepad.exe”
$ShortcutLocation = “C:\Users\thiyagu.a.selvaraj\Desktop\Notepad.lnk”

Step #2: The second step is to create a variable referencing a Wscript.Shell COM Object.

$WScriptShell = New-Object -ComObject WScript.Shell

Step #3: The third step is to add the target path to the method

$Shortcut = $WScriptShell.CreateShortcut($ShortcutLocation)
$Shortcut.TargetPath = $SourceFileLocation

Step #4: The final step is to envoke the Save() method to save your shortcut.

$Shortcut.Save()

Final Code

 

What do you think?

I hope you have an idea of  how to create the Create Shortcuts on Desktops using Powershell. I would like to have feedback from my posts readers. Your valuable feedback, question, or comments about this article are always welcome.