0
votes

I have been successfully using this little hack to programmatically PinToTaskbar in Windows 10.

$workingTarget = 'C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Accessories\WordPad.lnk'

$lmPropertyValue =  '{90AA3A4E-1CBA-4233-B8BB-535773D48449}'
$userClassKeys = (Get-Item 'HKCU:\SOFTWARE\Classes').OpenSubKey('*', $true)
$shellKey = $userClassKeys.CreateSubKey('shell', $true)
$verbKey = $shellKey.CreateSubKey('PxToolsWin10PinToTaskbar', $true)
$verbKey.SetValue('ExplorerCommandHandler', $lmPropertyValue)

$shell = New-Object -ComObject "Shell.Application"
$folder = $Shell.Namespace((Get-Item $workingTarget).DirectoryName)
$item = $folder.ParseName((Get-Item $workingTarget).Name)
$item.InvokeVerb("PxToolsWin10PinToTaskbar")


# Remove the temporary shell and verb keys
Remove-Item -path:'HKCU:\SOFTWARE\Classes\*\shell\PxToolsWin10PinToTaskbar' -recurse -force

It has worked fine, right up until the 1903 update. I have verified that the GUID has not changed, it still references pinToTaskbar, so not sure what Microsoft changed, but hopefully someone has a recommendation on how to make this work in the newest build.

For what it's worth, I DO know that Microsoft seems to think that IT in an office shouldn't be able to do this, or more correctly that developers shouldn't, and Microsoft's clumsy solution ALSO blocks firm IT. I find that interesting because Microsoft hasn't blocked Autodesk from putting things on the All User desktop, while a non local admin user is logged in, which is to my mind a MUCH more user hostile behavior. My goal is to pin to the USER's taskbar, to alert them to new software, while allowing them to manage those pinned items as they see fit after that initial pin. The right answer from Microsoft would be a group policy where I can just specifically enable certain programs to allow this, while all other programs are blocked. But to my knowledge that still sin't an option, so I keep looking for whacky workarounds to maintain needed functionality. :(

1

1 Answers

0
votes

Basically it's because the IContextMenu::InvokeCommand implementation checks whether the caller is explorer.exe. People have used PEB manipulation to work around that, but it's highly complicated.

I recently observed how Microsoft Edge (Chromium) managed to pin to Taskbar programmatically. Here's my blog entry about it.

IMPORTANT. Anyone gaining this knowledge should not try to pin the program you have written to the user without active and explicit consent.

But let's return to the OP's real question. If you just want to advertise new programs in a domain, you should Group Policy. The layout XML is reapplied every time its time stamp forwards. You can edit the file so that it only appends new pins.

Microsoft hasn't blocked Autodesk from putting things on the All User desktop, while a non local admin user is logged in

Not sure what OP meant by this. By default, a program cannot edit Public Desktop if it has no administrator privilege.

If OP means that every time Autodesk is run, it will check and place itself on Public Desktop, this means it has installed a service to do this for it at installation time. Note that the service could well be Windows Installer service --- any user can perform Repair on packages stored to a trusted location, and Windows Installer service will perform repairing as TrsutedInstaller. Note that this is not a security hole, because putting a package in a trusted location in the first place requires administrator privilege.