How to programmatically pin app to taskbar ?

Just starting out? Need help? Post your questions and find answers here.
vmars316
Enthusiast
Enthusiast
Posts: 474
Joined: Fri Jun 29, 2012 12:24 am
Contact:

How to programmatically pin app to taskbar ?

Post by vmars316 »

Hello & Thanks ;
Is it possible to pin an app to taskbar programmatically ?
Are there any examples ?
I am writing a tiny program that does one thing ,
it opens the Folder c:\myLauncher .
My simple plan is to fill c:\myLauncher with all the shortcuts that I use the most , sorted alphabetically .
And I want to pin the app to taskbar programmatically .
Hmm.. Curious-er and Curious-er :
Then of course I would need to be able to check if the program is pinned to taskbar .
Tiny program is not looking so tiny or simple anymore .
A batch script would be fine also . : )

Thanks
vmars.us Win11 x64 , Martin Guitar 000-16 (1995)
"All things in moderation , except for love and forgiveness."
Olli
Addict
Addict
Posts: 1071
Joined: Wed May 27, 2020 12:26 pm

Re: How to programmatically pin app to taskbar ?

Post by Olli »

What do you think about the systray ?
BarryG
Addict
Addict
Posts: 3322
Joined: Thu Apr 18, 2019 8:17 am

Re: How to programmatically pin app to taskbar ?

Post by BarryG »

vmars316 wrote:Is it possible to pin an app to taskbar programmatically ?
Apparently there is -> https://docs.microsoft.com/en-us/window ... to-taskbar

Don't ask me how to do that with PureBasic, though. I think that may be only for UWP apps, too.
User avatar
Derren
Enthusiast
Enthusiast
Posts: 313
Joined: Sat Jul 23, 2011 1:13 am
Location: Germany

Re: How to programmatically pin app to taskbar ?

Post by Derren »

Since you said a script would be OK, here's a PowerShell script (I haven't tested it) https://stackoverflow.com/questions/317 ... windows-10

You can run Powershell with RunProgramm and the "Hide"-Flag to hide from the user that you're using a Shell Script.
Rinzwind
Enthusiast
Enthusiast
Posts: 638
Joined: Wed Mar 11, 2009 4:06 pm
Location: NL

Re: How to programmatically pin app to taskbar ?

Post by Rinzwind »

Won't work in Windows 10 update x. It only returns the verb for pin (which is language specific) when it is requested from an application with the name Explorer.exe

They really wan't to prevent you doing this in code...
User avatar
ChrisR
Addict
Addict
Posts: 1150
Joined: Sun Jan 08, 2017 10:27 pm
Location: France

Re: How to programmatically pin app to taskbar ?

Post by ChrisR »

Yes, Pin to Tasbar doesn't work the same way since windows 10 1809
Before it was possible to do it quite easily using vbscript, powershell... with the verb Pin to TaskBar

I developed a little while ago, in PB, a tool: PinUtil, with the help of JFX, for the need of my Win10XPE project

It uses MasqueradePEB Procedure
to gives the appearance of explorer.exe process and so the "pin to taskbar" item will show up in context menu, bypassing MS simple trick To hide it.
Idea from PowerShell-Suite Masquerade-PEB.ps1

Then it uses IID_IContextMenu to Invoke the Context Menu for the File and Browse the Menu Items
If the Name Matches the Verb, the Associate Command is Called

x64/x86 exe are here : https://github.com/ChrisRfr/PinUtil
Usage1: PinUtil (TaskBar|StartMenu) File ["File 2" "File 9"]

Ex1: PinUtil TaskBar %windir%\System32\calc.exe
Ex2: PinUtil StartMenu "C:\Windows\System32\notepad.exe" "%windir%\System32\calc.exe"

Usage2: PinUtil Config ConfigFile [Section (Default=PinUtil)]

Ex: PinUtil Config %windir%\System32\PintUtil.ini

PinUtil.ini Limited To 9 Elements For TaskBar And StartMenu:
[PinUtil]
StartMenu1=%AllPrograms%\Accessories\Paint.lnk
StartMenu0=%WinDir%\Explorer.exe
TaskBar0=%SystemRoot%\System32\cmd.exe
TaskBar9=%SystemRoot%\Explorer.exe

Usage3: Pecmd ConfigFile [SubSection (Default=PinUtil)] (_SUB SubSection)
Pecmd is a command interpreter commonly used in WinPE (Windows PE )

Ex: PinUtil Pecmd %windir%\System32\Pecmd.ini PinUtil

Pecmd.ini
_SUB PinUtil
PINT %AllPrograms%\Accessories\Paint.lnk,StartMenu
PINT %WinDir%\Explorer.exe,StartMenu
PINT %SystemRoot%\System32\cmd.exe,TaskBar
PINT %SystemRoot%\Explorer.exe,TaskBar

Environment Variables are Available As Well As:
%StartMenu%, %Programs%, %ALLPrograms%, %Desktop%, %QuickLaunch%

Support StartIsback, Start10, Start8, Open-Shell, Classic Shell, Explorer7ForWin8, Windows 7 StartMenu

You Cannot Pin Applications from a Removable Media...
vmars316
Enthusiast
Enthusiast
Posts: 474
Joined: Fri Jun 29, 2012 12:24 am
Contact:

Re: How to programmatically pin app to taskbar ?

Post by vmars316 »

Thanks , I'll take a look at PinUtil .
vmars.us Win11 x64 , Martin Guitar 000-16 (1995)
"All things in moderation , except for love and forgiveness."
Post Reply