Create Shortcuts .lnk or .url Files With PowerShell


Have you ever needed to create shortcuts while scripting. Shortcuts are simply .lnk files with a few details highlighting a few details of the file that you would like to launch. Many people simply copy an already created shortcut. With PowerShell you can actually create a shortcut from scratch by utilizing the New-Object commandlet. Here is the quick run down with explanation.

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

Step #2: The second 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.

Step #3: The third step is to add the target path, any relevant arguments, along with anything else that may be required.

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

Step #5: As a bonus here is how you would create a Favorite in Windows which is a .url shortcut.

Print Friendly, PDF & Email


Leave a Reply