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


This is the application I am trying to add to the sytem tray

Code:
[HKEY_CURRENT_USER\Control Panel\NotifyIconSettings\987723032863792971]
"UID"=dword:000003e8
"ExecutablePath"="{7C5A40EF-A0FB-4BFC-874A-C0F2E0B9FA8E}\\Kaseya\\TCHCNT68342430089984\\KaUsrTsk.exe"
"InitialTooltip"="Agent"
 

My Computer

System One

  • OS
    11
    Computer type
    PC/Desktop
    Manufacturer/Model
    HP
This GUID is missing the IsPromoted subkey. I don't know if Kaseya's supposed to create this key for you.

reg.exe import this file.
Code:
Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Control Panel\NotifyIconSettings\987723032863792971]
"IsPromoted"=dword:00000001
 

My Computer

System One

  • OS
    Windows 7
Oh sorry. That subkey does exist, under the "IconSnapchot"=hex: and is as follows:
Code:
"IsPromoted"=dword:00000000
 

My Computer

System One

  • OS
    11
    Computer type
    PC/Desktop
    Manufacturer/Model
    HP
This is the script I am trying to run. I want this script to automatically move the Kaseya app from hidden in the system tray to unhidden.

Code:
function W11_TrayNotify {
    param (
        [Parameter(Mandatory)]
        [string[]] $AppList,

        [Parameter(Mandatory)]
        [ValidateSet('Unhide','Hide','Flip')]
        $Action
    )

    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) {
                switch ($Action) {
                    'Unhide' { $Promoted = 1 }
                    'Hide'  { $Promoted = 0 }
                    'Flip' { $Promoted = (Get-ItemProperty -Path $ChildPath -Name IsPromoted).IsPromoted -bxor 1 }
                }
                Set-ItemProperty -Path $ChildPath -Name IsPromoted -Value $Promoted
            }
        }
    }
}

W11_TrayNotify -AppList @("Kaseya", "KaUsrTsk") -Action Unhide
 

My Computer

System One

  • OS
    11
    Computer type
    PC/Desktop
    Manufacturer/Model
    HP
Thank you I will have a look at that page.

Changing the value to 1 unhides the icon but the script doesn't seem to do it. I'd like to automate the process using the script.
 

My Computer

System One

  • OS
    11
    Computer type
    PC/Desktop
    Manufacturer/Model
    HP
Can you export the entire Kaseya GUID to a reg file? I need an actual intact extract to debug.
 

My Computer

System One

  • OS
    Windows 7
This is the entire GUID for Kaseya excluding "IconSnapshot"

Code:
Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Control Panel\NotifyIconSettings\987723032863792971]
"UID"=dword:000003e8
"ExecutablePath"="{7C5A40EF-A0FB-4BFC-874A-C0F2E0B9FA8E}\\Kaseya\\TCHCNT68342430089984\\KaUsrTsk.exe"
"InitialTooltip"="Agent"
"IsPromoted"=dword:00000000
 

My Computer

System One

  • OS
    11
    Computer type
    PC/Desktop
    Manufacturer/Model
    HP
Hi Garlin, revelation: The script works when I right click the .ps1 file and 'Run with PowerShell' but doesn't work when I run it in PowerShell ISE directly
 

My Computer

System One

  • OS
    11
    Computer type
    PC/Desktop
    Manufacturer/Model
    HP
There should be no differences, unless you're running a different PS (6 or 7). ISE is PS 5.
But the two PS'es have separate Execution Policy settings...
 

My Computer

System One

  • OS
    Windows 7
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

Howdy! Great work! Very useful. In my testing on Windows 10, it does get the icon to show, however subsequent runs it seems to be flipping the value regardless of the setting chosen. Hide/Unhide/etc.
 

My Computer

System One

  • OS
    Windows 10
I haven't seen that before. The default behavior is flipping the icon state, unless it recognizes a '-Hide" or "-Unhide" in the command line.
 

My Computer

System One

  • OS
    Windows 7
Back
Top Bottom