Al seguente Configure the applications pinned to the taskbar vengono fornite le informazioni per Windows 10 e Windows 11 su come gestire centralmente, ad esempio tramite Group policy, le applicazioni aggiunte (pinned) alla barra delle applicazioni (Taskbar).
Sebbene su questo tema vi siano state varie novità come ad esempio quelle introdotte in Windows 11 24H2 con la KB5060829 o in Windows 11 23H2 con la KB5060826 occorre precisare che vi sono alcuni aspetti di cui tenere conto.
In estrema sintesi la gestione la gestione centralizzata delle applicazioni nella barra delle applicazioni avviene tramite un file xml che descrive quali applicazioni vanno aggiunte nella barra delle applicazioni. L’utilizzo del file xml da parte del sistema avviene impostandone l’utilizzo mediante la relativa group policy computer o utente:
- Computer Configuration > Administrative Templates > Start Menu and Taskbar > Start Layout
- User Configuration > Administrative Templates > Start Menu and Taskbar > Start Layout
Ovviamente il file xml dovrà essere disponibile su una condivisione di rete configurata con gli opportuni privilegi di accesso oppure essere copiato localmente, come vedremo in seguito la copia in locale consente di ovviare ad un comportamento di default.
Nel caso in cui si voglia ad esempio aggiungere alla barra delle applicazioni le applicazioni Edge, Outlook, Word, Excel e Esplora file è possibile utilizzare il seguente file xml:
<?xml version=”1.0″ encoding=”utf-8″?>
<LayoutModificationTemplate
xmlns=”http://schemas.microsoft.com/Start/2014/LayoutModification”
xmlns:defaultlayout=”http://schemas.microsoft.com/Start/2014/FullDefaultLayout”
xmlns:start=”http://schemas.microsoft.com/Start/2014/StartLayout”
xmlns:taskbar=”http://schemas.microsoft.com/Start/2014/TaskbarLayout”
Version=”1″>
<CustomTaskbarLayoutCollection>
<defaultlayout:TaskbarLayout>
<taskbar:TaskbarPinList>
<taskbar:DesktopApp DesktopApplicationID=”MsEdge”/>
<taskbar:DesktopApp DesktopApplicationID=”Microsoft.Office.OUTLOOK.EXE.15″/>
<taskbar:DesktopApp DesktopApplicationID=”Microsoft.Office.WINWORD.EXE.15″/>
<taskbar:DesktopApp DesktopApplicationID=”Microsoft.Office.EXCEL.EXE.15″/>
<taskbar:DesktopApp DesktopApplicationID=”Microsoft.Windows.Explorer”/>
</taskbar:TaskbarPinList>
</defaultlayout:TaskbarLayout>
</CustomTaskbarLayoutCollection>
</LayoutModificationTemplate>
Occorre però precisare come funziona la gestione del file xml perché si potrebbe essere portati ad aspettarsi un comportamento differente nella gestione delle applicazioni aggiunte nella barra delle applicazioni tramite Group Policy.
Di seguito alcune informazioni estratte da Configure the applications pinned to the taskbar di cui occorre tenere presente:
- If you specify an app to be pinned that isn’t provisioned for the user on the device, the pinned icon doesn’t appear on the taskbar
- The order of applications in the XML file dictates the order of pinned apps on the taskbar, from left to right. If the OS is configured to use a right-to-left language, then the taskbar order is reversed
- By default, any pins provisioned via policy settings are restored upon the next policy update cycle, even when users unpin them
- Starting with Windows 11, version 24H2 with KB5060829 and 23H2 with KB5060826, users can unpin apps pinned via policy settings, if allowed by the policy. The pins won’t be repinned during the next policy update cycle
- Applications can be pinned using the following methods:
- Default Windows apps, pinned during the OS installation. For example: Microsoft Edge, File Explorer, and Store. These applications are pinned first
- Pinned manually by the user. These applications are pinned next to the default pinned apps
- Pinned via policy settings. These applications are pinned after the apps pinned manually by the user
Depending on the method you use to configure the taskbar, the configuration is reapplied at different intervals. When the taskbar configuration is reapplied, user changes are overwritten.
In the <CustomTaskbarLayoutCollection> node, the apps you add are pinned after the default apps. If you want to remove the default apps, and only show the apps you add in the XML file, then add PinListPlacement=”Replace”:
- <CustomTaskbarLayoutCollection>: Keeps the default pinned apps. After the default apps, the apps you add are pinned
- <CustomTaskbarLayoutCollection PinListPlacement=”Replace”>: Unpins the default apps. Only the apps you add are pinned. If you want to remove some of the default pinned apps, then add PinListPlacement=”Replace”. When you add your apps to <taskbar:TaskbarPinList>, include the default apps you still want pinned
Starting with Windows 11, version 24H2 with KB5060829 and 23H2 with KB5060826, you can allow certain pinned apps to be unpinned by users. This is useful when you want to allow users to unpin apps that are pinned via policy settings, but you don’t want the pins to be pinned again during the next policy update cycle.
To use this option, add PinGeneration=”1″ to the pins you want to allow users to unpin. The value of PinGeneration can be any number, and it’s used to identify the pin version. If the value changes, the app is pinned again during the next policy update cycle. This allows IT admins to repin an app, if needed.
Here’s the logic used by PinGeneration:
- When PinGeneration isn’t defined, users can unpin that element, but the pin is repinned during the next policy update cycle
- When PinGeneration is defined, users can unpin that element, and the pin isn’t repinned during the next policy update cycle
- When the PinGeneration value changes, for example from 1 to 2, the element is pinned again, even if the user unpinned it previously
- Every PinGeneration number is specific to an app. You can define a value of 1 for one app, and a value of 2 for another app
- If you remove the PinGeneration attribute, the app is repinned during the next policy update cycle even if the user unpinned it previously. This is the default behavior
Some tips for using PinGeneration:
- Define PinGeneration with a starting value of 1 and increment the number each time you want to repin the app. This way, if the user unpins the app, it’s not repinned until you change the number again
- For simple management, always increment the PinGeneration number and don’t reuse numbers
The GPO applies the Start and taskbar layout at the next user sign-in. Each time the user signs in, the timestamp of the .xml file with the Start and taskbar layout is checked and if a newer version of the file is available, the settings in the latest version of the file are applied.
After the taskbar layout is applied, users must sign out and sign in again to get the new layout. Unless prohibited via policy settings, users can add pins, remove pins, and change their order.
- By default, any pins provisioned via policy settings are restored upon the next policy update cycle, even when users unpin them
- Pins defined with the PinGeneration attribute can be unpinned from the taskbar, and aren’t repinned during the next policy update cycle
Starting with Windows 11 Insider Preview Build 26200.5722 (Dev Channel) and 26120.5722 (Beta Channel), taskbar pin configurations deployed via policy are applied instantly, without requiring the user to sign out and sign back in.
Sintetizzando possiamo dire che:
- Quando si imposta un layout alla barra delle applicazioni questo viene applicato al prossimo login dell’utente, nelle prossime versioni di Windows 11 il layout potrà essere applicato all’atto dell’applicazione delle policy
- Dopo che la policy ha applicato il layout l’utente può comunque cambiare l’ordine delle applicazioni o eliminarle e queste modifiche rimarranno persistenti fino a che non verrà distribuito un file xml diverso oppure come ho potuto osservare se la data di modifica del file xml cambia.
- Il layout viene riapplicato se il file xml è modificato in base al ciclo di refresh delle group policy e quanto ciò avviene possono verificarsi le seguenti:
- Se un utente ha modificato l’ordine delle applicazioni questo non verrà ristabilito.
- Se un utente elimina una o più applicazioni queste verranno aggiunte nuovamente (a meno che venga utilizzata l’opzione PinGeneration disponibile in Windows 11 23h2 e 24H2) in coda alle esistenti o a quelle eventualmente aggiunte dall’utente.
- Se non si desidera che l’utente possa modificare la barra delle applicazioni occorre utilizzare la seguente group policy utente: User Configuration > Policies > Administrative Templates > Start Menu and Taskbar > Prevent changes to Taskbar and Start Menu Settings
Quindi se si desidera che alcune applicazioni siano sempre presenti nella barra delle applicazioni indipendentemente dal fatto che l’utente le possa rimuovere, ma si vuole comunque che l’utente possa anche aggiungere altre applicazioni occorre che la policy che applica il file xml del layout lo rilevi sempre come modificato quando scatta il ciclo di refresh delle group policy.
Per ottenere questo comportamento è necessario copiare in un percorso locale il file xml ad esempio tramite una group policy prefences computer e sempre tramite una group policy preferences computer creare una operazone pianificata che viene eseguita con l’account NT AUTHORITY\SYSTEM che all’avvio del computer avvierà uno script per aggiornare la data di modifica del file xml. In questo modo quando verrà applicata la group policy che imposta il layout della barra delle applicazione il layout verrà riapplicato.
Per informazioni sulle Group Policy Preferences si veda Working with Windows Settings Preference Items Using the GPMC.
Per far si che la data di modifica del file xml venga aggiornata ci possono essere vari approcci, io ho preferito un approccio semplice basato su uno script DOS che non fa altro che creare un nuovo file xml con lo stesso contenuto del file xml originale mediante l’istruzione TYPE, ovvero un file clone dell’originale, e quindi sostituire il file originale con il file clone.
Ipotizzando ad esempio che il file del layout sia denominato TaskbarLayout.xml è possibile creare un file Rewrite-TaskbarLayout.xml nella stessa cartella del file TaskbarLayout.xml con queste istruzioni:
SET filename=TaskbarLayout.xml
SET file=%~dp0%filename%
SET filetmp=%file%.tmpIF EXIST %filetmp% DEL /Q /F %filetmp%
TYPE “%file%” > “%file%.tmp”DEL /Q /F “%file%”
REN “%filetmp%” “%filename%”
Anche in questo si può pensare di copiare lo script mediante una group policy prefences computer, dal momento che lo script verrò eseguito con l’account NT AUTHORITY\SYSTEM è importante che la cartella in cui risiede lo script sia opportunamente protetta in modo che lo script non possa essere alterato, a riguardo si vedano le considerazioni che aveo fatto nel post Automazione operazioni su client Active Directory tramite scripts: considerazioni e hardening – DevAdmin Blog.
In alternativa se si preferisce è anche possibile creare uno script PowerShell che va a modificare la proprietà LastWriteTime del file xml, a riguardo si veda Use PowerShell to Modify File Access Time Stamps – Scripting Blog [archived].
Ovviamente dopo aver visto sia le potenzialità che i limiti della gestione delle applicazioni nella barra delle applicazioni tramite un file di layout (come ad esempio l’impossibilità di gestire un ordine delle applicazione che venga rispettato ad ogni applicazione del layout e alla necessità di trovare un workaroud per forzare l’applicazione del layout anche quando il file non è stato modificato, ma sono intervenute modifiche da parte dell’utente) viene da chiedersi se sarebbe possibile gestire le applicazioni nella barra delle applicazioni tramite uno script o tool a riga di comando.
Putroppo, sebbene esistano delle API documentate per la gestione della taskbar, Microsoft impone una serie di regole per l’utilizzo di tai API, come illustrato in Pin your app to the taskbar – Windows apps | Microsoft Learn, che di fatto redono l’utilizzo di tali API utile solo quando il pin di un’applicazione sulla Taskbar è fatta dall’utente:
The TaskbarManager class lets you ask the user to pin your app to the taskbar; the user must approve the request. You put a lot of effort into building a stellar app, and now you have the opportunity to ask the user to pin it to taskbar. But before we dive into the code, here are some things to keep in mind as you are designing your experience:
- Do craft a non-disruptive and easily dismissible UX in your app with a clear call to action. Avoid using dialogs and flyouts for this purpose. Accessible pinning icons or similar UX is recommended but not required.
- Do ensure your app has value to the user before asking the user to pin it.
- Don’t ask a user to pin your app if the tile is already pinned or the device doesn’t support it. (This article explains how to determine whether pinning is supported.)
- Don’t repeatedly ask the user to pin your app (they will probably get annoyed).
- Don’t call the pin API without explicit user interaction or when your app is minimized/not open. Your app must be in the foreground for the process to work.
- Don’t use installers to call the API.
Taskbar Pinning is a Limited Access Feature on some versions of Windows.
The limited access restriction is being removed from Windows starting with KB5074105 (OS Builds 26200.7705 and 26100.7705)
Per un esempio di codice si veda Taskbar pinning sample – Code Samples | Microsoft Learn.
Queste limitazioni sono state indicate anche nel seguente post A principled approach to app pinning and app defaults in Windows | Windows Experience Blog:
For pinning, we will soon introduce a new publicly available API that will enable apps to pin either primary or secondary tiles to the Taskbar. This API will always invoke a trusted Windows user experience to clarify what is being requested to be pinned and to confirm that the user indeed wants to allow the pin to occur.
Conceptual UX for pinning confirmation when called by an application. (Not final Experience.)
As a platform we also believe that to deliver the trust, safety and security that customers look to Windows to provide, we have a responsibility to ensure user choices are respected. We have taken and will continue to take steps to mitigate unrequested modifications to a user’s choices and expect to do more later this year after application developers have had time to incorporate these new best practices.
Viene quindi da chiedersi se sia possibile accedere alle API che il sistema utilizza quando l’utente esegue l’azione di aggiugere o rimuovere un’applicazione dalla barra delle applicazioni, come è stato risposto sul repositori Github dei PowerToys da uno sviluppatore del progetto le API il 13 marzo 2026 al momento le API per la gestione della Taskbar sono private e non documentate a riguardo si questa risposta in Provide a documented API for taskbar customization (transparency, sizing, positioning) · Issue #46111 · microsoft/PowerToys:
We can’t do this with a PowerToys utility because the APIs for manipulating the Taskbar are private/undocumented. Microsoft is rumoured to be working on improving Taskbar customisation, but this would be via an update to Windows itself.
Concludendo quindi, al momento, l’utilizzo di Layout XML + Group Policy è il metodo consigliato per l’amministrazione centralizzata di un layout taskbar centralizzato in ambienti gestiti (GPO/MDM).
Capisco perfettamente, è un’ottima soluzione per mantenere l’organizzazione delle applicazioni, soprattutto in un ambiente aziendale.