# ChipRestart.ps1 v1.1 # Restarts the Chip agent and tray, downloading the latest tray version first. # Run this if Chip seems unresponsive, or after a tray layout update. $ErrorActionPreference = 'SilentlyContinue' $DIR = 'C:\ComputerHelper' $ServerBase = 'https://helper.tekdr.net' Write-Host ' Chip Restart starting...' -ForegroundColor Cyan # Stop agent Get-CimInstance Win32_Process | Where-Object { $_.CommandLine -like '*chip-agent*' } | ForEach-Object { Stop-Process -Id $_.ProcessId -Force -ErrorAction SilentlyContinue } # Stop tray Get-CimInstance Win32_Process | Where-Object { $_.CommandLine -like '*ChipTray*' } | ForEach-Object { Stop-Process -Id $_.ProcessId -Force -ErrorAction SilentlyContinue } Start-Sleep -Seconds 2 Write-Host ' Stopped agent and tray.' -ForegroundColor Gray # Download latest ChipTray.ps1 before restarting # This delivers new window sizes, icon updates, and bug fixes. Write-Host ' Downloading latest tray...' -ForegroundColor Gray try { $wc = New-Object System.Net.WebClient $wc.DownloadFile("$ServerBase/api/tray-update", "$DIR\ChipTray.ps1") Write-Host ' Tray updated.' -ForegroundColor Green } catch { Write-Host ' Could not download latest tray (will use existing version).' -ForegroundColor Yellow } # Clear icon cache -- both old and new filenames Remove-Item "$DIR\chip-icon-v72.png" -Force -ErrorAction SilentlyContinue Remove-Item "$DIR\chip-icon-v80.png" -Force -ErrorAction SilentlyContinue # Restart agent via scheduled task; start tray through the per-user logon task. Start-ScheduledTask -TaskName 'ChipAgent' Write-Host ' Agent started.' -ForegroundColor Green Start-Sleep -Seconds 4 $tray = "$DIR\ChipTray.ps1" if (Test-Path $tray) { Start-ScheduledTask -TaskName 'ChipTrayUserLogon' -TaskPath '\Chip\' -ErrorAction SilentlyContinue } Write-Host ' Tray started.' -ForegroundColor Green Start-Sleep -Seconds 3 Write-Host '' Write-Host ' Done! Chip has restarted with the latest version.' -ForegroundColor Green Write-Host ' The tray icon should appear in a few seconds.' -ForegroundColor White