Access the Windows taskbar

Hello everybody,

How would you list the shortcuts in the Windows 11 taskbar ?

My aim is to launch a search on them. You do not ignore that Windows is notoriously unable to lock the taskbar, which means that a hazardous mouse slide will move the shortcut on which the mouse pointed, and you may have difficulties to find it again.

So, if in answer to a part of the text as a search key, the list is displayed with a different colour for the shortcuts of which the text contains the search key, that can be handy to find the shortcut again.

Well, if it is possible to restore the good order, it would be even better.

Are you reffering to “pinned” items or running items. it would take more research to see if the running items can be exposed but the pinned items can be looked at as follows.

$PossiblyPinnedApps = (New-Object -Com Shell.Application).NameSpace(‘shell:::{4234d49b-0245-4df3-b780-3893943456e1}’).Items()

If you share your code we can help you better, show us what you have scripted so far.

In addition we need to know if you meant to say apps “pinned” to the task bar or apps running in the task bar? In my example the $PossiblyPinnedApps object will have a property called “Verbs” and one type of Verb will have a property called “Name” and that name will match the string “Unpin from taskbar“ if it is pinned. Otherwise that property will not exist. The Verb object will have a method named “DoIt” that method if executed properly will remove the pinned item, or you can recurse through all of them and remove them all.

or you can search for that first string I gave you on the internet and you’ll find all kinds of people using that in scripts. Such as Chris Titus who is known for his DeBloat scripting. However if unpinning is not what you’re trying to do then you need to provide more details and what you have tried so far so we can help you.

Thank you.

I recognise elements in the results, except they are 298, and I should like to determine the 25 that I can see in the taskbar.

Perhaps putting them into an array can help, and it seems I do not do it straight forward …

$PossiblyPinnedApps = (New-Object -Com Shell.Application).NameSpace(‘shell:::{4234d49b-0245-4df3-b780-3893943456e1}’).Verbs();
 $tab[500] = new Array(Shell.Application);
 $i=0;
 foreach($a in $PossiblyPinnedApps)
 {
   $tab[$i] = $a;
   $i++;
 }

I have got a null array error, possibly I am influenced by C# …

It seems the name and path properties will be useful, but some elements have quite valid name and path properties, and do not appear in the taskbar, so should not be considered in the results.

Or maybe the namespace refers to the start menu?

This part isn’t working for me. The “.Verbs()” method at the end returns an error that the method doesn’t exist.

The second line doesn’t make any sense to me. $Tab isn’t defined ahead of time but you’re indexing into the 501 st object in it? Then “new array()” isn’t proper PowerShell syntax, so maybe this is where your C# is bleeding through. In any case, I can’t tell what you’re trying to accomplish there.
As an aside, you don’t need to end any lines with ; as a regular carriage return accomplishes the same thing. You can use ; on a single line if you’re trying to string things together.

I tried this code:

$possiblypinnedapps = (New-Object -Com Shell.Application).NameSpace(‘shell:::{4234d49b-0245-4df3-b780-3893943456e1}’)
$Items = $possiblepinnedapps.Items()

An then explored the $Items object for a bit. It seems to contain almost everything in my start menu, with no property to me that indicates whether it exists on the task bar or not.

I did some searching and came across this gist that’s also using some of the same methodology shared by @vern_anderson

It looks like the objects returned can reveal verbs that include “pin” and "unpin”, but from exploring my own computer it’s not consistent. An unpinned app doesn’t necessarily contain the “pin to taskbar” verb, and vice-versa, a pinned app doesn’t necessarily contain the “unpin from taskbar” verb.


Well, if the question is badly asked, it is difficult to answer it correctly, of course.

To convert an object to an array, in C# you add “.toArray()”, in PowerShell it is like that:

$arr = @($PossiblyPinnedApps);
$arr.count
$arr[0]

And this displays me the number of elements, and the contents of the first one.

The advantage is that I can address any item with its index, whereas with $PossiblyPinnedApps (defined in the first answer) you have to use a foreach loop.

Verbs was an attempt to access an element, it was somewhat hazardous.

Sorry to have had an hesitation about this.

So, as verbs you got pin and unpin, but with no real consequence about whether it is visible or not on the taskbar.

Well, anyway, it was to access the element, to be able for instance to add it to an array, but that is done.

Do you have an idea about the fact I get 298 elements, and the taskbar only displays 25?

There are two possible explanations, either all the elements are not visible, or the used class corresponds to something else. Well in the properties of the items I get Browsable, but this seems to be something else.

Not sure what the ultimate goal is here, but you can get the pinned items from this location:

$items = Get-ChildItem -Path "$ENV:Appdata\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar"

Was surprised to see the reference to “Internet Explorer” still exists even on Win11.

Thanks @tonyd , this was much easier to run and look at than the other message. I’m worried about its accuracy however. I have 8 items pinned to my taskbar and this returned 6 of them. However, I tested pinning Putty to the taskbar really quick and it immediately showed up in the list.

This method you shared can also be more specific about the user you wish to do this for. Instead of $env:appdata I could pass c:\users\username\appdata\roaming and pull the list of pinned items for that specific user.

Thank you very much, this time I have a little less items than shortcuts in the taskbar, but maybe some always appear.

Going to work on this and see what I can do, thank you.

Oh yes, Internet Explorer is not a new thing :slight_smile:

Oh, but I get a surprise: the listed items are present in the taskbar, but not in the same order at all.

Considering the aim was to help find an element with its name, the order is important.

Any idea on that?

***

I listed C:\Users\User\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar

in the order of update (DIR /TW /OD), in the order of last access (DIR /TA /OD), not better.

Getting the order is bound to be ugly. Have a look in the registry here:

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Taskband

There are two values, “Favorites” and “FavoritesResolve” which are both binary. The order in those binary values “seems” to reflect the left to right order of the items in the TaskBar. Have fun with that.

If you want to get this information for others, you need to grab their

%Userprofile%\NTUSER.dat

file which is locked if they are logged in.

Oh, it seems to be …

And … I imagine there is no doc about that?

Well, thank you.

So … For 30 shortcuts in the taskbar, including the four that are not listed, I got 40 Kbytes of compact data with no space, and no clue about what 00600100003A001F80C827341F105C1042AA032EE45287D668260001002600EFBE12000000474 means.

Thank you for the fun :slight_smile:

In fact, going back to Windows 10 could be a solution, as it can lock the taskbar.

Not likely, at least not that I am aware of. Parsing the binary data for ASCII strings would be a starting point, and somehow correlate that to the folder items found. But that is a challenge and likely not worth the effort. Way out of my league for sure.

OK, I just had to give this a try. Maybe you can work with this. In my test, the results were returned in the order on the taskbar. Your mileage may vary.

[Array]$itm = Get-ItemPropertyValue 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Taskband\' -Name 'FavoritesResolve'
ForEach($asciiChar in $itm) {$Result += [Char]$asciiChar -join ''}
$pattern = 'OSDisk(.*?)lnk'
$matches = [regex]::Matches($Result, $pattern)
$matches.Value


Oh I see.

There must be Thunderbird somewhere in there, so there must be a T, 84, so with the calculator in programmer mode I see in hexadecimal that makes 54, and then an h, 104 → 68, then the u must be 75 the same way.

Oh, and in Favorites I see somewhere “005400680075”.

On a good way, isn’t it?

With Hxd I see that Thunderbird is “54 68 75 6E 64 65 72 62 69 72 64”.

Well I am going to look at your last message, it seems you found something faster.

A good revision about the regular expressions …

I have executed your script.

What do I do of this?

PS C:\Scripts\PowerShell> $itm[0]
240
PS C:\Scripts\PowerShell> $itm[1]
2
PS C:\Scripts\PowerShell> $itm[2]
0
PS C:\Scripts\PowerShell> $itm[3]
0

better said like this:

PS C:\Scripts\PowerShell> "`n  `{0}{2}; `{0}{1}{0}{2}]" -f "$", "itm[", "i";for($i=0;$i -le 10; $i++) {"{0,3} : {1,3}" -f $i, $itm[$i];}

  $i; $itm[$i]
  0 : 240
  1 :   2
  2 :   0
  3 :   0
  4 :  76
  5 :   0
  6 :   0
  7 :   0
  8 :   1
  9 :  20
 10 :   2

I beg to differ. It looks like you executed ONE line of the entire script.

The first line simple grabs the binary data from the registry key.
The second line then converts the binary data to ascii characters for parsing.
The third line defines the regex for extracting what we want from the ascii characters.
The fourth line apples the regex and obtains the matches.
The last line displays the matchs which should contain all the shortcuts in order on your taskbar..

Execute the entire script, line by line and $matches.Value should get you what you want.

OK, thanks.

I had an hesitation as I had nothing in matches. It seems I have to adapt the pattern. After getting the Result, with no filter, it becomes clearer.

Each shortcut appears three times, with different formatting. But it is much clearer with characters than with their codes :slight_smile:

I have to notice what is repeated in front of each item, and then extract the useful text.

Seems promising.