In this tutorial, I will explain how to create desktop shortcuts with custom icons using PowerShell. As an IT administrator, I recently faced the challenge of creating desktop shortcuts for various applications with specific icons on multiple user computers. Let me show you now how to do this.
Create Desktop Shortcuts with Custom Icons Using PowerShell
To create a desktop shortcut using PowerShell, we’ll use a script that uses the WScript.Shell object. Here’s a basic example of the script:
$TargetFile = "C:\Program Files\Mozilla Firefox\firefox.exe"
$ShortcutFile = "C:\Users\Public\Desktop\Firefox.lnk"
$IconLocation = "C:\Program Files\Mozilla Firefox\firefox.exe, 0"
$WScriptShell = New-Object -ComObject WScript.Shell
$Shortcut = $WScriptShell.CreateShortcut($ShortcutFile)
$Shortcut.TargetPath = $TargetFile
$Shortcut.IconLocation = $IconLocation
$Shortcut.Save()Let’s break down the script:
$TargetFile: This variable specifies the path to the executable file for which you want to create the shortcut. In this example, it points to the Firefox executable.$ShortcutFile: This variable defines the path and name of the shortcut file that will be created on the desktop. Here, we’re creating a shortcut named “Firefox.lnk” in the Public Desktop folder.$IconLocation: This variable specifies the location of the icon file and its index. In this case, we’re using the default Firefox icon located within the Firefox executable.$WScriptShell: This line creates an instance of theWScript.Shellobject, which is used to create the shortcut.$Shortcut: This variable represents the shortcut object created using theCreateShortcut()method of theWScript.Shellobject.- The remaining lines set the
TargetPathandIconLocationproperties of the shortcut object and save the shortcut file using theSave()method.
Check out Create a Self-Signed Certificate Using PowerShell
Customize the PowerShell Script
Now that you understand the basic script, let’s customize it to create shortcuts for different applications with custom icons. Here’s an example:
$TargetFile = "C:\Program Files\Google\Chrome\Application\chrome.exe"
$ShortcutFile = "C:\Users\Public\Desktop\Google Chrome.lnk"
$IconLocation = "C:\Program Files\Google\Chrome\Application\chrome.exe, 0"
$WScriptShell = New-Object -ComObject WScript.Shell
$Shortcut = $WScriptShell.CreateShortcut($ShortcutFile)
$Shortcut.TargetPath = $TargetFile
$Shortcut.IconLocation = $IconLocation
$Shortcut.Save()In this example, we’re creating a shortcut for Google Chrome with its default icon. Simply adjust the $TargetFile, $ShortcutFile, and $IconLocation variables to match the desired application and icon.
You can also specify a separate icon file by modifying the $IconLocation variable. For example:
$IconLocation = "C:\Icons\CustomIcon.ico, 0"This line sets the icon location to a custom icon file named “CustomIcon.ico” located in the “C:\Icons” directory.
Check out Disable Windows Firewall Using PowerShell
Execute the PowerShell Script
To run the PowerShell script and create the desktop shortcut, follow these steps:
- Open PowerShell as an administrator.
- Navigate to the directory where you saved the script file.
- Execute the script by running the following command:
.\CreateShortcut.ps1Replace “CreateShortcut.ps1” with the actual name of your script file.
- PowerShell will execute the script, and the desktop shortcut will be created with the specified target file and icon.
Check out Create a Local Admin Account Using PowerShell
Automate Shortcut Creation for Multiple Applications
To streamline the process of creating shortcuts for multiple applications, you can create a PowerShell script that defines an array of application details and iterates over them to create shortcuts. Here’s an example:
$Applications = @(
@{
TargetFile = "C:\Program Files\Microsoft Office\root\Office16\WINWORD.EXE"
ShortcutFile = "C:\Users\Public\Desktop\Microsoft Word.lnk"
IconLocation = "C:\Program Files\Microsoft Office\root\Office16\WINWORD.EXE, 0"
},
@{
TargetFile = "C:\Program Files\Microsoft Office\root\Office16\EXCEL.EXE"
ShortcutFile = "C:\Users\Public\Desktop\Microsoft Excel.lnk"
IconLocation = "C:\Program Files\Microsoft Office\root\Office16\EXCEL.EXE, 0"
},
@{
TargetFile = "C:\Program Files\Microsoft Office\root\Office16\POWERPNT.EXE"
ShortcutFile = "C:\Users\Public\Desktop\Microsoft PowerPoint.lnk"
IconLocation = "C:\Program Files\Microsoft Office\root\Office16\POWERPNT.EXE, 0"
}
)
$WScriptShell = New-Object -ComObject WScript.Shell
foreach ($App in $Applications) {
$Shortcut = $WScriptShell.CreateShortcut($App.ShortcutFile)
$Shortcut.TargetPath = $App.TargetFile
$Shortcut.IconLocation = $App.IconLocation
$Shortcut.Save()
}In this script, we define an array called $Applications that contains hash tables representing the details of each application. Each hash table includes the TargetFile, ShortcutFile, and IconLocation properties.
The script then iterates over the $Applications array using a foreach loop. For each application, it creates a shortcut using the WScript.Shell object, sets the TargetPath and IconLocation properties, and saves the shortcut file.
By running this script, you can automatically create desktop shortcuts for multiple applications with their respective icons in one go.

Conclusion
In this tutorial, I explained how to create desktop shortcuts with custom icons using PowerShell. You also learned how to deploy shortcuts on multiple user computers using PowerShell. By using the WScript.Shell object, you can easily create shortcuts for various applications with specific icons.
You may also like:
- Create a Credential Object in PowerShell
- Create a PowerShell Module
- Create a Registry Key with PowerShell If It Does Not Exist
- Set Service to Automatic Using PowerShell
Bijay Kumar is an esteemed author and the mind behind PowerShellFAQs.com, where he shares his extensive knowledge and expertise in PowerShell, with a particular focus on SharePoint projects. Recognized for his contributions to the tech community, Bijay has been honored with the prestigious Microsoft MVP award. With over 15 years of experience in the software industry, he has a rich professional background, having worked with industry giants such as HP and TCS. His insights and guidance have made him a respected figure in the world of software development and administration. Read more.