12/28/2022 0 Comments Powershell create lnk file![]() ![]() 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" 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. Let’s consider a requirement to create a shortcut for Microsoft Edge using PowerShell script. 3 Conclusion PowerShell Create Shortcut to File ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |