Skip to content

Commit c7a4259

Browse files
committed
Add user context check to tray icon script
1 parent 7dc36cc commit c7a4259

1 file changed

Lines changed: 45 additions & 9 deletions

File tree

scripts/superops_tray_icon_always_show.ps1

Lines changed: 45 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ $ErrorActionPreference = 'Stop'
88
███████╗██║██║ ╚═╝ ██║███████╗██║ ██║██║ ██║╚███╔███╔╝██║ ██╗
99
╚══════╝╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝╚═╝ ╚═╝ ╚══╝╚══╝ ╚═╝ ╚═╝
1010
================================================================================
11-
SCRIPT : SuperOps Tray Icon Always Show v1.1.0
11+
SCRIPT : SuperOps Tray Icon Always Show v1.2.0
1212
AUTHOR : Limehawk.io
1313
DATE : December 2024
1414
USAGE : .\superops_tray_icon_always_show.ps1
@@ -18,9 +18,15 @@ $ErrorActionPreference = 'Stop'
1818
README
1919
--------------------------------------------------------------------------------
2020
PURPOSE
21-
Configures Windows system tray settings to always show the SuperOps RMM
22-
agent tray icon. This ensures the SuperOps icon remains visible in the system
23-
tray notification area rather than being hidden in the overflow area.
21+
22+
*** MUST RUN AS LOGGED-IN USER - NOT SYSTEM ***
23+
24+
Configures Windows system tray settings to always show the SuperOps RMM
25+
agent tray icon. This ensures the SuperOps icon remains visible in the
26+
system tray notification area rather than being hidden in the overflow.
27+
28+
Modifies HKCU registry which is per-user. Running as SYSTEM will modify
29+
SYSTEM's registry, not the user's - and will have no effect.
2430
2531
DATA SOURCES & PRIORITY
2632
1) Windows Registry (HKCU:\Control Panel\NotifyIconSettings)
@@ -44,10 +50,11 @@ $ErrorActionPreference = 'Stop'
4450
- No restart required - changes take effect on next tray icon update
4551
4652
PREREQUISITES
47-
- PowerShell 5.1 or later
48-
- Must run in user context (uses HKCU registry hive)
49-
- SuperOps agent must be installed (creates notification icon entries)
50-
- No elevation required (modifies current user's registry only)
53+
54+
- PowerShell 5.1 or later
55+
- *** MUST RUN AS LOGGED-IN USER (NOT SYSTEM) ***
56+
- SuperOps agent must be installed (creates notification icon entries)
57+
- No elevation required (modifies current user's registry only)
5158
5259
SECURITY NOTES
5360
- No secrets or credentials used
@@ -91,8 +98,9 @@ $ErrorActionPreference = 'Stop'
9198
--------------------------------------------------------------------------------
9299
CHANGELOG
93100
--------------------------------------------------------------------------------
101+
2024-12-28 v1.2.0 Added user context check, made warning more obvious
94102
2024-12-23 v1.1.0 Updated to Limehawk Script Framework
95-
2025-11-02 v1.0.0 Initial release
103+
2024-11-02 v1.0.0 Initial release
96104
================================================================================
97105
#>
98106

@@ -108,6 +116,34 @@ $iconsModified = 0
108116
$notifyIconPath = "HKCU:\Control Panel\NotifyIconSettings"
109117
$searchPattern = "*superops*"
110118

119+
# ==== USER CONTEXT CHECK ====
120+
Write-Host ""
121+
Write-Host "[ USER CHECK ]"
122+
Write-Host "--------------------------------------------------------------"
123+
124+
$currentUser = [System.Security.Principal.WindowsIdentity]::GetCurrent().Name
125+
Write-Host "Running as : $currentUser"
126+
127+
if ($currentUser -match "SYSTEM$") {
128+
Write-Host ""
129+
Write-Host "[ ERROR OCCURRED ]"
130+
Write-Host "--------------------------------------------------------------"
131+
Write-Host "This script must run as the logged-in user, not SYSTEM"
132+
Write-Host ""
133+
Write-Host "Tray icon settings are per-user (stored in HKCU)."
134+
Write-Host "Running as SYSTEM modifies SYSTEM's registry, not the user's."
135+
Write-Host ""
136+
Write-Host "Solutions:"
137+
Write-Host " - RMM: Run as 'logged-in user' instead of 'SYSTEM'"
138+
Write-Host " - GPO: Use a logon script"
139+
Write-Host " - Manual: Run from user's PowerShell session"
140+
Write-Host ""
141+
Write-Host "[ SCRIPT COMPLETED ]"
142+
Write-Host "--------------------------------------------------------------"
143+
exit 1
144+
}
145+
Write-Host "Context is valid (not SYSTEM)"
146+
111147
# ==== VALIDATION ====
112148
if (-not (Test-Path $notifyIconPath)) {
113149
$errorOccurred = $true

0 commit comments

Comments
 (0)