Add Desktop Icon To Taskbar [patched] 〈TESTED — 2025〉
$shortcut = (Get-ChildItem "$env:USERPROFILE\Desktop\*.lnk" | Where-Object $_.Name -like "*MyApp*").FullName $shell = New-Object -ComObject Shell.Application $target = (New-Object -ComObject WScript.Shell).CreateShortcut($shortcut).TargetPath $shell.Namespace(0x0a).ParseName($target).InvokeVerb("taskbarpin")
This method reveals a key Windows behavior: The right-click menu for a desktop icon sometimes includes (for .exe shortcuts) and sometimes does not (for .url or folders). Microsoft restricts this to avoid cluttering the Taskbar with non-launchable items. add desktop icon to taskbar
Pinned icon opens wrong program or does nothing. Cause: The original desktop shortcut had command-line arguments or a specific working directory that you lost. Fix: Create a new shortcut to the .exe including arguments, then pin that new shortcut’s target. $shortcut = (Get-ChildItem "$env:USERPROFILE\Desktop\*