fix(install-windows): don't let a missing Ollama process abort the last step

taskkill writes to stderr when the process isn't running, and with
$ErrorActionPreference = Stop PowerShell 5.1 promotes native stderr to a
terminating error (2>$null doesn't prevent it). The normal case -- Ollama not
running -- threw and printed a failure warning for work that had succeeded.
Uses Get-Process | Stop-Process instead.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
jon
2026-07-22 14:51:44 -05:00
co-authored by Claude Opus 4.8
parent 18df04c5d8
commit 38af74581f
+10 -2
View File
@@ -228,8 +228,16 @@ try {
Remove-Item $ollamaAutostart -Force
Write-OK "Removed Ollama login autostart"
}
foreach ($img in @("ollama app.exe", "ollama.exe")) {
taskkill /F /T /IM $img 2>$null | Out-Null
# Get-Process, not taskkill: taskkill writes "ERROR: The process ... not
# found." to stderr when nothing is running, and with $ErrorActionPreference
# = Stop PowerShell 5.1 promotes a native command's stderr to a TERMINATING
# error. `2>$null` does not prevent that. So the ordinary case - Ollama
# simply is not running - aborted this whole block and printed the warning
# below, claiming the install could not configure something it had in fact
# already done. Cmdlets have no such trap.
foreach ($name in @("ollama app", "ollama")) {
Get-Process -Name $name -ErrorAction SilentlyContinue |
Stop-Process -Force -ErrorAction SilentlyContinue
}
Write-OK "Ollama set to manual start"
} catch {