![powerhsell create lnk file powerhsell create lnk file](https://renenyffenegger.ch/notes/Windows/dirs/Windows/System32/cmd_exe/start/start-in-empty.png)
In the above PowerShell script, first we define location and path for shortcut folder. $ShortcutPath = "C:\Users\admin\Desktop\powershell.lnk" Let’s consider, we have to create a shortcut to folder available on D:\ drive and save shortcut on user desktop.Ĭopy below PowerShell script and run it on your computer to create shortcut with PowerShell.
POWERHSELL CREATE LNK FILE HOW TO
In this example, I will explain you how to create shortcut to folder on user desktop or on remote computer with PowerShell. $shortcut = $WscriptObj.CreateShortcut($ShortcutPath)Ĭool Tip: Do you know how to get free disk space using PowerShell! PowerShell Create shortcut to Folder $WScriptObj = New-Object -ComObject ("WScript.Shell") $ShortcutPath = "C:\Users\Gary.Thomas\Desktop\MsEdge.lnk"
![powerhsell create lnk file powerhsell create lnk file](https://www.uperesia.com/img/articles/shortcut/booby_trapped_shortcut_icon_and_properties.png)
POWERHSELL CREATE LNK FILE CODE
Step #7: PowerShell Create Shortcut Code $SourceFilePath = "C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe" lnk $ShortcutPath = "C:\Users\Gary.Thomas\Desktop\MsEdge.lnk" Step 3: Create new WScript.Shell object and assign it to variable $WScriptObj = New-Object -ComObject ("WScript.Shell") Step #4: Create Shortcut using shortcut path specified in Step 2 $shortcut = $WscriptObj.CreateShortcut($ShortcutPath) Step #5: Add Target Path or other relevant arguments to shortcut variable $shortcut.TargetPath = $SourceFilePathĬool Tip: How to map network drive in PowerShell! Step #6: Use Save() method $shortcut.Save()Ībove program demonstrates, using PowerShell to create shortcut on desktop for user. When we run entire PowerShell script, it will create shortcut file to the user desktop with provided name. Step #1 Define source file location of Microsoft Edge $SourceFilePath = "C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe"Ĭool Tip: Query Active Directory users info using PowerShell! Step #2: Define shortcut file location and name of shortcut file. You must have the Windows Script host on your computer to run the below script. Let’s look at given below PowerShell script to create shortcut for Microsoft Edge on desktop.
![powerhsell create lnk file powerhsell create lnk file](https://i0.wp.com/securityaffairs.co/wordpress/wp-content/uploads/2018/11/sLoad.png)
Let’s consider a requirement to create a shortcut for Microsoft Edge using PowerShell script. 3 Conclusion PowerShell Create Shortcut to File