Trying to make an application in the system tray show up in the active window for all machines


gnynot

New member
Local time
1:06 AM
Posts
4
OS
Windows 11
I'm using win11 23H2

I want to use GPO, Powershell or registry to move a application that is hidden in the system tray to the active area. I know I can do this by clicking that option there but I'm trying to do this for 1000 machines. Is it possble for me to do this in a massive deployment.


1700166885711.png
 

My Computer

System One

  • OS
    Windows 11
    Computer type
    Laptop
    Manufacturer/Model
    surface 5
Unhiding notification icons is simple enough, but you have to search under "HKCU\Control Panel\NotifyIconSettings" as each subkey has a random GUID name. I wrote two versions of a script.

This version reverses the current hiding state, for every app matching the command line arguments. The app name is whatever ExecutablePath appears under NotifyIconSetttings registry.
Code:
powershell -f Toggle_NotifyIcon.ps1 OneDrive SecurityHealth
Toggle_NotifyIcon.ps1
Code:
$AppList = $args

foreach ($GUID in (Get-ChildItem -Path 'HKCU:\Control Panel\NotifyIconSettings' -Name)) {
    $ChildPath = "HKCU:\Control Panel\NotifyIconSettings\$($GUID)"
    $Exec = (Get-ItemProperty -Path $ChildPath -Name ExecutablePath -ErrorAction SilentlyContinue).ExecutablePath

    foreach ($App in $AppList) {
        if ($Exec -match $App) {
            $Current_State = (Get-ItemProperty -Path $ChildPath -Name IsPromoted).IsPromoted
            Set-ItemProperty -Path $ChildPath -Name IsPromoted -Value ($Current_State -bxor 1)
        }
    }
}

This version forces each of the named apps as visible. You could remove the 2nd foreach, and replace it with a single if-statement.
Unhide_NotifyIcon.ps1
Code:
$AppList = $args

foreach ($GUID in (Get-ChildItem -Path 'HKCU:\Control Panel\NotifyIconSettings' -Name)) {
    $ChildPath = "HKCU:\Control Panel\NotifyIconSettings\$($GUID)"
    $Exec = (Get-ItemProperty -Path $ChildPath -Name ExecutablePath -ErrorAction SilentlyContinue).ExecutablePath

    foreach ($App in $AppList) {
        if ($Exec -match $App) {
            Set-ItemProperty -Path $ChildPath -Name IsPromoted -Value 1
        }
    }
}

Windows 10 x64-2023-11-16-20-20-47.png
Windows 10 x64-2023-11-16-20-20-58.png
 
Last edited:

My Computer

System One

  • OS
    Windows 7
This is perfect. Thank you so much garlin. I modified your script a little to only do one application.
 
Last edited:

My Computer

System One

  • OS
    Windows 11
    Computer type
    Laptop
    Manufacturer/Model
    surface 5
Hey garlin, Just curious do you happen to know if I can make a Windows10 version of this powershell script?
 

My Computer

System One

  • OS
    Windows 11
    Computer type
    Laptop
    Manufacturer/Model
    surface 5
I searched the web, and found a W10 example in stevencohn's Set-NotifyIcon.ps1.

The code was really longer than needed, but I simplified and merged it with my script, and it works on both W10 & W11.

Now the script takes three optional arguments. The default is to flip (reverse) the current settings. App names are case-insensitive, and may require quotes when running on W10.
Code:
Set-TrayNotify.ps1 -Hide OneDrive "vm tools"
Set-TrayNotify.ps1 -Unhide OneDrive

Set-TrayNotify.ps1 -Flip OneDrive
Set-TrayNotify.ps1 OneDrive
 

Attachments

  • Set-TrayNotify.ps1
    4.3 KB · Views: 18
Last edited:

My Computer

System One

  • OS
    Windows 7
Garlin, This is amazing. I really appreciate it.
 

My Computer

System One

  • OS
    Windows 11
    Computer type
    Laptop
    Manufacturer/Model
    surface 5
Hi All. Does this work on windows 11 too? I have been attempting to utilize this script to no avail.

For some reason despite having unrestricted execution policy, PowerShell states that the Registry locations identified in the script don't exist.
 

My Computer

System One

  • OS
    11
    Computer type
    PC/Desktop
    Manufacturer/Model
    HP
This script works on W11 23H2 (tested it just now). Are you running as Administrator?
What's the exact error message?
 

My Computer

System One

  • OS
    Windows 7
Admin mode enabled. Running the full script SetTrayNotify.ps1 with no changes
 

Attachments

  • Screenshot 2024-01-15 162224.png
    Screenshot 2024-01-15 162224.png
    7.9 KB · Views: 2

My Computer

System One

  • OS
    11
    Computer type
    PC/Desktop
    Manufacturer/Model
    HP
You must provide the script one or more arguments. Like the App(s) you're trying to Hide/Unhide.

If you don't know the App's "name", then open regedit. Search under HKEY_CURRENT_USER\Control Panel\NotifyIconSettings, and expand the GUID keys until you see the ExecutablePath.
The script performs a simple string match, so "OneDrive" is enough to specify OneDrive as the target app.

1705297381608.png
 

My Computer

System One

  • OS
    Windows 7
I apologize, I am new to PowerShell. I have the executable location and name but where in the script would I insert it.
 

My Computer

System One

  • OS
    11
    Computer type
    PC/Desktop
    Manufacturer/Model
    HP
If you want, call any of the two functions directly.

1. Remove the last few lines of PS code below the end of the function blocks.
2. Replace with:
Code:
W11_TrayNotify -AppList @("App1") -Action Hide

W10_TrayNotify -AppList @("App1", "App2", "App3") -Action Unhide
 

My Computer

System One

  • OS
    Windows 7
I just want a certain task to force unhide from the system tray. This is how I have the script setup. I removed the windows 10 function block as it's not needed in my instance. When replacing "App1" with the appropriate app, the script gives no errors but does not remove the application from hidden in the system tray.

Please see attached
 

Attachments

  • ModifiedSetTrayNotify.ps1
    1.6 KB · Views: 4

My Computer

System One

  • OS
    11
    Computer type
    PC/Desktop
    Manufacturer/Model
    HP
Are you running as Admin? You need rights to update the registry.
 

My Computer

System One

  • OS
    Windows 7
Yes running as admin. Does the script look correct?
 

My Computer

System One

  • OS
    11
    Computer type
    PC/Desktop
    Manufacturer/Model
    HP
You need to remove the block above the first comments. That block is irrelevant if you're not passing any script-level arguments.
 

My Computer

System One

  • OS
    Windows 7
Script just runs - No errors - item remains hidden in the system tray
 

My Computer

System One

  • OS
    11
    Computer type
    PC/Desktop
    Manufacturer/Model
    HP
Can you regedit export your "HKCU\Control Panel\NotifyIconsSettings"?
 

My Computer

System One

  • OS
    Windows 7
I meant for you to post the exported reg file, so we can see what you're trying to modify.
 

My Computer

System One

  • OS
    Windows 7

Latest Support Threads

Back
Top Bottom