-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall.ps1
More file actions
64 lines (55 loc) · 2.56 KB
/
Copy pathinstall.ps1
File metadata and controls
64 lines (55 loc) · 2.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# install.ps1 — one-shot installer for the Claude Usage Dashboard tray app.
#
# Run from an interactive PowerShell session (no admin required for
# per-user Task Scheduler entries):
#
# powershell -ExecutionPolicy Bypass -File .\install.ps1
#
# The script:
# 1. Locates trayapp.exe (next to the script unless -ExePath overrides).
# 2. Registers a per-user Task Scheduler "at logon" task so the tray
# starts automatically (preferred over shell:startup; survives RDP).
#
# The price table no longer needs bootstrapping: the canonical prices.yaml
# is embedded in the binary (see prices_embed.go), so cost computation works
# with zero configuration. To override rates without a rebuild, drop a
# prices.yaml next to trayapp.exe or in %APPDATA%\usage_dashboard\ — see
# docs/configuration.md "Price table resolution".
#
# Re-running is safe: the scheduled task is replaced in-place.
#
# This script is documented in docs/tray-app.md ("Autostart") but not
# executed in CI — it's a Windows-only post-build step.
[CmdletBinding()]
param(
[string]$ExePath = (Join-Path $PSScriptRoot 'trayapp.exe'),
[string]$TaskName = 'ClaudeUsageDashboard'
)
$ErrorActionPreference = 'Stop'
if (-not (Test-Path $ExePath)) {
throw "trayapp.exe not found at '$ExePath'. Build it first with: go build -ldflags=`"-H=windowsgui`" -o trayapp.exe ./cmd/trayapp"
}
# --- Register Task Scheduler "at logon" task ---------------------------------
$fullUser = if ($env:USERDOMAIN) { "$env:USERDOMAIN\$env:USERNAME" } else { $env:USERNAME }
$action = New-ScheduledTaskAction -Execute $ExePath
$trigger = New-ScheduledTaskTrigger -AtLogOn -User $fullUser
$principal = New-ScheduledTaskPrincipal -UserId $fullUser -LogonType Interactive -RunLevel Limited
$settings = New-ScheduledTaskSettingsSet `
-AllowStartIfOnBatteries `
-DontStopIfGoingOnBatteries `
-StartWhenAvailable `
-ExecutionTimeLimit (New-TimeSpan -Hours 0)
if (Get-ScheduledTask -TaskName $TaskName -ErrorAction SilentlyContinue) {
Unregister-ScheduledTask -TaskName $TaskName -Confirm:$false
Write-Host "Removed existing scheduled task '$TaskName'."
}
Register-ScheduledTask `
-TaskName $TaskName `
-Action $action `
-Trigger $trigger `
-Principal $principal `
-Settings $settings `
-Description 'Claude Usage Dashboard tray app (auto-start at logon).' | Out-Null
Write-Host "Registered scheduled task '$TaskName' to launch '$ExePath' at logon."
Write-Host "Done. The tray app will start automatically on next logon, or run it now with:"
Write-Host " Start-ScheduledTask -TaskName $TaskName"