Need to remove old outlook shortcut and unpinned from taskbar

TechUST 606 Reputation points
2024-02-08T23:05:52.4166667+00:00

Hi Techie,

I recently observed in my environment that both the old outlook and new outlook are pinned to the taskbar. I need a script that can remove the old outlook shortcut and simultaneously unpin it from the taskbar. I have tried below script, which removes the shortcut from this path %APPDATA%\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar\outlook.link. However, it does not unpin it from the taskbar. When I click on the old outlook icon on the taskbar, it says "it might be deleted, moved, or renamed. Do you want to remove item?" I restarted many times but but outlook icon not removing on taskbar,
My goal is to remove the shortcut and also unpin it from the taskbar.    

                                                                  @echo off
REM Unpinning Outlook from taskbar
powershell -Command "& {$tbs = New-Object -ComObject Shell.Application; $tbs.Namespace('C:\ProgramData\Microsoft\Windows\Start Menu\Programs').Items() | ? {$_.Name -eq 'Outlook'} | % {$_.InvokeVerb('Unpin from Taskbar')}}"
 
REM Removing old Outlook shortcut from taskbar
DEL /F /S /Q /A "%AppData%\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar\Outlook.lnk"
 
REM Deleting registry key
REG DELETE "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Taskband" /v FavoritesRemoved /f
 
REM Restarting explorer.exe
taskkill /f /im explorer.exe
start explorer.exe

 

Windows for business | Windows Client for IT Pros | Directory services | Active Directory
Windows for business | Windows Server | User experience | PowerShell
Microsoft Security | Intune | Configuration
Windows for business | Windows Client for IT Pros | User experience | Other
Microsoft System Center | Other
{count} votes

2 answers

Sort by: Most helpful
  1. XinGuo-MSFT 22,231 Reputation points
    2024-02-09T07:34:37.9966667+00:00

    Hi,

    Based on my test, please replace the first line of your script with the following command.

    powershell -Command "& {((New-Object -Com Shell.Application).NameSpace('shell:::{4234d49b-0245-4df3-b780-3893943456e1}').Items() | ?{$_.Name -like '*Outlook*'}).Verbs() | ?{$_.Name.replace('&','') -match 'Unpin from taskbar'} | %{$_.DoIt()}}" 
    
    
    0 comments No comments

  2. Pavel yannara Mirochnitchenko 13,341 Reputation points MVP
    2024-02-09T11:39:17.97+00:00

    I would create totally new set for taskbar and replace all original icons:

    <?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 PinListPlacement="Replace"> defaultlayout:TaskbarLayout taskbar:TaskbarPinList <taskbar:DesktopApp DesktopApplicationID="windows.immersivecontrolpanel_cw5n1h2txyewy!microsoft.windows.immersivecontrolpanel"/> <taskbar:DesktopApp DesktopApplicationID="Microsoft.Windows.Explorer"/> <taskbar:DesktopApp DesktopApplicationID="MSEdge"/> <taskbar:DesktopApp DesktopApplicationID="Microsoft.Office.OUTLOOK.EXE.15"/> <taskbar:UWA AppUserModelID ="Microsoft.CompanyPortal_8wekyb3d8bbwe!App"/> <taskbar:UWA AppUserModelID ="MicrosoftTeams_8wekyb3d8bbwe!App"/> <taskbar:DesktopApp DesktopApplicationLinkPath="%SystemRoot%\cmtrace.exe"/> </taskbar:TaskbarPinList> </defaultlayout:TaskbarLayout> </CustomTaskbarLayoutCollection> </LayoutModificationTemplate>

    User's image


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.