Create shortcut to .exe using PowerShell

Create a ShortCut for an Exe File

Creating a shortcut to an application on multiple end user desktops can be a laborious task. However, the process is pretty straightforward when using a PowerShell script. In the following script, provide the path of the EXE file and the exact path where the shortcut has to be created as parameters and run the script. The necessary shortcut will be created at the required place. 

Script

<#
.SYNOPSIS
This script can be used to Create a ShortCut for an Exe File
.DESCRIPTION
This script can be used to Create a ShortCut for an Exe File
.EXAMPLE
C:\PS> C:\Script\Create_a_shortcut.ps1 C:\Program Files (x86)\Mozilla Firefox\firefox.exe C:\Users\gautam-2374\Desktop\Firefox.lnk
Create a ShortCut for an Exe File in Desktop.
#>

param ( [string]$ExePath, [string]$ShortcutPath )
#Use the New-Object cmdlet to create an instance of the Wscript.Shell object

$WshShell = New-Object -comObject WScript.Shell
#As soon as we have that object in hand we can then use the CreateShortcut method to create a new shortcut in memory

$Shortcut = $WshShell.CreateShortcut($ShortcutPath)
$Shortcut.TargetPath = $ExePath
$Shortcut.Save()

 

 



    • Related Articles

    • Determine version of Exe or Dll

      IT administrators need to compare the version information of the EXE or DLL files. This can be critical because, the version numbers indicate whether a software patch has been applied or not. However sifting through multiple version numbers of all ...
    • Clear Contents of a File

      Temporary files can take up considerable space in a database and eventually slow down computers. Administrators can use the following PowerShell script to completely clear the contents of files remotely. If you want to delete the entire text file ...
    • Create a shared folder

      Provisioning and managing shared folders through the native Windows process is a pretty straightforward process. However, things can get quickly out of hand when you need to manage multiple shares across multiple computers. With PowerShell, you can ...
    • Remove read only property of a file

      A common issue that administrators face while restoring files from their backups is that the read-only property of the files comes marked by default. This can cause serious trouble as end users will not be able to edit their documents without ...
    • Create a mailbox database in Exchange Server

      Manually provisioning mailbox databases to new users can be arduous. However, administrators can turn to PowerShell scripts to create mailbox database easily. The below script will create a mailbox database in an Exchange Server with the name 'D10'. ...