Skip to content

Commit 0a92575

Browse files
committed
Release v1.3.0 single-entry tray integration
1 parent 7c829f4 commit 0a92575

6 files changed

Lines changed: 203 additions & 105 deletions

CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
11
# Changelog
22

3+
## v1.3.0 - 2026-05-16
4+
5+
Single-entrypoint tray integration release.
6+
7+
### Added
8+
9+
- Optional tray-mode install prompt in `Install-GWRouterLogger.ps1` with a short explanation of what the tray mode provides.
10+
- Internal tray support module loaded through `GW-Router-Logger.ps1 -TrayApp` instead of a second user-facing script entry.
11+
12+
### Changed
13+
14+
- The main script is now the only launch target for installed shortcuts.
15+
- Tray self-updates now reinstall tray mode without re-prompting during the handoff.
16+
- Installer-created shortcuts now point either to console mode or tray mode depending on the selected install option.
17+
- Uninstall cleanup now stops tray instances launched through `GW-Router-Logger.ps1 -TrayApp`.
18+
319
## v1.2.1 - 2026-05-16
420

521
Startup and log-layout polish release.
Lines changed: 90 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,9 @@
1-
param(
2-
[switch] $FirewallOnly,
3-
[switch] $SelfTest,
4-
[switch] $ListenerSelfTest,
5-
[switch] $UpdateCheckSelfTest,
6-
[switch] $StartListener,
7-
[int] $FirewallUdpPort = 514,
8-
[int] $FirewallTcpPort = 0
9-
)
10-
11-
# GW Router Logger tray application.
12-
# This file keeps the listener usable without a console window and leaves the
13-
# original CLI script intact for users who prefer the menu-driven terminal flow.
1+
# GW Router Logger tray support module.
2+
# This keeps tray behavior behind the main GW-Router-Logger.ps1 entrypoint so
3+
# installs only expose one app script to the user.
144

155
$script:AppName = 'GW Router Logger'
16-
$script:Version = '1.2.1'
6+
$script:Version = '1.3.0'
177
$script:Publisher = 'Ghostwheel'
188
$script:GitHubOwner = 'GhostwheeI'
199
$script:GitHubRepo = 'GW-Router-Logger'
@@ -67,6 +57,10 @@ function Get-ScriptRootPath {
6757
return Split-Path -Parent $MyInvocation.MyCommand.Path
6858
}
6959

60+
function Get-LauncherScriptPath {
61+
return Join-Path -Path (Get-ScriptRootPath) -ChildPath 'GW-Router-Logger.ps1'
62+
}
63+
7064
function Get-AppDataRoot {
7165
if (-not [string]::IsNullOrWhiteSpace($env:ProgramData)) {
7266
$programDataPath = Join-Path -Path $env:ProgramData -ChildPath 'GW-Router-Logger'
@@ -285,7 +279,9 @@ try {
285279
'-ExecutionPolicy', 'Bypass',
286280
'-File', `$installerPath,
287281
'-InstallPath', `$InstallRoot,
288-
'-ForceReinstall'
282+
'-ForceReinstall',
283+
'-InstallTrayMode',
284+
'-SkipTrayPrompt'
289285
)
290286
291287
if ((Test-IsProtectedInstallPath -Path `$InstallRoot) -and -not (Test-IsAdministrator)) {
@@ -507,7 +503,7 @@ function Sync-StartupShortcut {
507503
$wsh = New-Object -ComObject WScript.Shell
508504
$shortcut = $wsh.CreateShortcut($shortcutPath)
509505
$shortcut.TargetPath = "$env:WINDIR\System32\WindowsPowerShell\v1.0\powershell.exe"
510-
$shortcut.Arguments = '-NoProfile -ExecutionPolicy Bypass -WindowStyle Hidden -Sta -File "{0}"' -f $PSCommandPath
506+
$shortcut.Arguments = '-NoProfile -ExecutionPolicy Bypass -WindowStyle Hidden -Sta -File "{0}" -TrayApp' -f (Get-LauncherScriptPath)
511507
$shortcut.WorkingDirectory = Get-ScriptRootPath
512508
$shortcut.Description = 'Start GW Router Logger in the notification area'
513509
$iconPath = Get-AppIconPath
@@ -900,7 +896,7 @@ function Add-FirewallRulesForConfig {
900896
$args = @(
901897
'-NoProfile',
902898
'-ExecutionPolicy', 'Bypass',
903-
'-File', ('"{0}"' -f $PSCommandPath),
899+
'-File', ('"{0}"' -f (Get-LauncherScriptPath)),
904900
'-FirewallOnly',
905901
'-FirewallUdpPort', ([string] $(if ([bool] $Config.UdpEnabled) { [int] $Config.UdpPort } else { 0 })),
906902
'-FirewallTcpPort', ([string] $(if ([bool] $Config.TcpEnabled) { [int] $Config.TcpPort } else { 0 }))
@@ -2038,75 +2034,89 @@ function Invoke-UpdateCheckSelfTest {
20382034
'UPDATE_CHECK_OK {0} {1}' -f $releaseInfo.Version, $releaseInfo.AssetName
20392035
}
20402036

2041-
if ($FirewallOnly) {
2042-
Invoke-FirewallOnlyMode
2043-
exit 0
2044-
}
2045-
2046-
if ($SelfTest) {
2047-
Invoke-SelfTest
2048-
exit 0
2049-
}
2050-
2051-
if ($ListenerSelfTest) {
2052-
Invoke-ListenerSelfTest
2053-
exit 0
2054-
}
2037+
function Start-GWRouterLoggerTrayApp {
2038+
param(
2039+
[switch] $FirewallOnly,
2040+
[switch] $SelfTest,
2041+
[switch] $ListenerSelfTest,
2042+
[switch] $UpdateCheckSelfTest,
2043+
[switch] $StartListener,
2044+
[int] $FirewallUdpPort = 514,
2045+
[int] $FirewallTcpPort = 0
2046+
)
20552047

2056-
if ($UpdateCheckSelfTest) {
2057-
Invoke-UpdateCheckSelfTest
2058-
exit 0
2059-
}
2048+
if ($FirewallOnly) {
2049+
Invoke-FirewallOnlyMode
2050+
return
2051+
}
20602052

2061-
$createdNew = $false
2062-
$mutex = New-Object System.Threading.Mutex($true, 'Global\GW-Router-Logger-Tray', [ref] $createdNew)
2063-
if (-not $createdNew) {
2064-
[void] [System.Windows.Forms.MessageBox]::Show(
2065-
'GW Router Logger is already running.',
2066-
$script:AppName,
2067-
[System.Windows.Forms.MessageBoxButtons]::OK,
2068-
[System.Windows.Forms.MessageBoxIcon]::Information
2069-
)
2070-
exit 0
2071-
}
2053+
if ($SelfTest) {
2054+
Invoke-SelfTest
2055+
return
2056+
}
20722057

2073-
try {
2074-
[System.Windows.Forms.Application]::EnableVisualStyles()
2075-
[System.Windows.Forms.Application]::SetCompatibleTextRenderingDefault($false)
2076-
Get-AppConfig | Out-Null
2077-
2078-
Build-ContextMenu
2079-
$script:NotifyIcon = New-Object System.Windows.Forms.NotifyIcon
2080-
$script:NotifyIcon.Icon = Get-AppIcon
2081-
$script:NotifyIcon.Text = $script:AppName
2082-
$script:NotifyIcon.ContextMenuStrip = $script:ContextMenu
2083-
$script:NotifyIcon.Visible = $true
2084-
2085-
$script:UiTimer = New-Object System.Windows.Forms.Timer
2086-
$script:UiTimer.Interval = 1000
2087-
$script:UiTimer.Add_Tick({ Update-MenuState })
2088-
$script:UiTimer.Start()
2058+
if ($ListenerSelfTest) {
2059+
Invoke-ListenerSelfTest
2060+
return
2061+
}
20892062

2090-
Update-MenuState
2091-
Write-AppLog -Message ('Tray startup reached. StartListener={0}' -f [bool] $StartListener)
2092-
if ($StartListener) {
2093-
Start-Listener
2063+
if ($UpdateCheckSelfTest) {
2064+
Invoke-UpdateCheckSelfTest
2065+
return
20942066
}
2095-
Write-AppLog -Message 'Tray application started.' -Diagnostic
2096-
[System.Windows.Forms.Application]::Run()
2097-
}
2098-
finally {
2099-
Stop-Listener
2100-
if ($script:UiTimer) {
2101-
$script:UiTimer.Stop()
2102-
$script:UiTimer.Dispose()
2067+
2068+
$createdNew = $false
2069+
$mutex = New-Object System.Threading.Mutex($true, 'Global\GW-Router-Logger-Tray', [ref] $createdNew)
2070+
if (-not $createdNew) {
2071+
[void] [System.Windows.Forms.MessageBox]::Show(
2072+
'GW Router Logger is already running.',
2073+
$script:AppName,
2074+
[System.Windows.Forms.MessageBoxButtons]::OK,
2075+
[System.Windows.Forms.MessageBoxIcon]::Information
2076+
)
2077+
return
21032078
}
2104-
if ($script:NotifyIcon) {
2105-
$script:NotifyIcon.Visible = $false
2106-
$script:NotifyIcon.Dispose()
2079+
2080+
try {
2081+
[System.Windows.Forms.Application]::EnableVisualStyles()
2082+
[System.Windows.Forms.Application]::SetCompatibleTextRenderingDefault($false)
2083+
Get-AppConfig | Out-Null
2084+
2085+
Build-ContextMenu
2086+
$script:NotifyIcon = New-Object System.Windows.Forms.NotifyIcon
2087+
$script:NotifyIcon.Icon = Get-AppIcon
2088+
$script:NotifyIcon.Text = $script:AppName
2089+
$script:NotifyIcon.ContextMenuStrip = $script:ContextMenu
2090+
$script:NotifyIcon.Visible = $true
2091+
2092+
$script:UiTimer = New-Object System.Windows.Forms.Timer
2093+
$script:UiTimer.Interval = 1000
2094+
$script:UiTimer.Add_Tick({ Update-MenuState })
2095+
$script:UiTimer.Start()
2096+
2097+
Update-MenuState
2098+
Write-AppLog -Message ('Tray startup reached. StartListener={0}' -f [bool] $StartListener)
2099+
if ($StartListener) {
2100+
Start-Listener
2101+
}
2102+
Write-AppLog -Message 'Tray application started.' -Diagnostic
2103+
[System.Windows.Forms.Application]::Run()
21072104
}
2108-
if ($mutex) {
2109-
$mutex.ReleaseMutex()
2110-
$mutex.Dispose()
2105+
finally {
2106+
Stop-Listener
2107+
if ($script:UiTimer) {
2108+
$script:UiTimer.Stop()
2109+
$script:UiTimer.Dispose()
2110+
}
2111+
if ($script:NotifyIcon) {
2112+
$script:NotifyIcon.Visible = $false
2113+
$script:NotifyIcon.Dispose()
2114+
}
2115+
if ($mutex) {
2116+
$mutex.ReleaseMutex()
2117+
$mutex.Dispose()
2118+
}
21112119
}
21122120
}
2121+
2122+
Export-ModuleMember -Function Start-GWRouterLoggerTrayApp

GW-Router-Logger.ps1

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
param(
2+
[switch] $TrayApp,
3+
[switch] $FirewallOnly,
4+
[switch] $SelfTest,
5+
[switch] $ListenerSelfTest,
6+
[switch] $UpdateCheckSelfTest,
7+
[switch] $StartListener,
8+
[int] $FirewallUdpPort = 514,
9+
[int] $FirewallTcpPort = 0
10+
)
11+
112
$ErrorActionPreference = 'Stop'
213
Set-StrictMode -Version 2
314

@@ -14,7 +25,7 @@ catch {
1425
# These script-scoped values act as the main tuning points for future maintenance.
1526
# Keeping them together makes it easier to adjust behavior without searching the file.
1627
$script:AppName = 'GW Router Logger'
17-
$script:Version = '1.2.1'
28+
$script:Version = '1.3.0'
1829
$script:MaxCompressedBytes = 100MB
1930
$script:ActiveLogRotateBytes = 5MB
2031
$script:ActiveLogRotateMinutes = 60
@@ -29,6 +40,24 @@ $script:TcpClientIdleTimeoutMinutes = 15
2940
$script:LastSettings = $null
3041
$script:SourceNameCache = @{}
3142

43+
if ($TrayApp -or $FirewallOnly -or $SelfTest -or $ListenerSelfTest -or $UpdateCheckSelfTest -or $StartListener) {
44+
$trayModulePath = Join-Path -Path (Split-Path -Path $PSCommandPath -Parent) -ChildPath 'GW-Router-Logger.TrayMode.psm1'
45+
if (-not (Test-Path -LiteralPath $trayModulePath)) {
46+
throw "Tray support module is missing: $trayModulePath"
47+
}
48+
49+
Import-Module -Name $trayModulePath -Force -DisableNameChecking
50+
Start-GWRouterLoggerTrayApp `
51+
-FirewallOnly:$FirewallOnly `
52+
-SelfTest:$SelfTest `
53+
-ListenerSelfTest:$ListenerSelfTest `
54+
-UpdateCheckSelfTest:$UpdateCheckSelfTest `
55+
-StartListener:$StartListener `
56+
-FirewallUdpPort $FirewallUdpPort `
57+
-FirewallTcpPort $FirewallTcpPort
58+
return
59+
}
60+
3261
function Write-Rule {
3362
param(
3463
[int] $Width = 72,

0 commit comments

Comments
 (0)