Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions libs/cua-driver/scripts/install-local.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,35 @@ if ($AutoStart) {
catch {
Write-Host " Failed to register: $($_.Exception.Message)" -ForegroundColor Red
}
} else {
# User didn't pass -AutoStart, but if a `cua-driver-serve` task is
# ALREADY registered (from a previous `install.ps1 -AutoStart` or
# `cua-driver autostart enable`), re-register it pointing at this
# fresh binary. Otherwise the user ends up with a task whose
# <Command> path is the OLD release-install dir, running the OLD
# binary - even though `cua-driver` on PATH now resolves to the
# fresh one. See trycua/cua#1654 (hidden-console wrapper landed
# later - old tasks that survived an upgrade still produce the
# visible console window at logon).
$prevEAP = $ErrorActionPreference
$ErrorActionPreference = 'Continue'
try {
& schtasks.exe /Query /TN "cua-driver-serve" 2>$null | Out-Null
$hasTask = ($LASTEXITCODE -eq 0)
} finally {
$ErrorActionPreference = $prevEAP
}
if ($hasTask) {
Write-Step "found existing 'cua-driver-serve' task - re-registering against fresh binary"
try {
Register-CuaDriverAutostart -InstalledBinary (Join-Path $VisibleBinDir $BinaryName)
Write-Host " Re-registered. Task action now uses this build's hidden-console wrapper." -ForegroundColor Green
}
catch {
Write-Host " Failed to re-register: $($_.Exception.Message)" -ForegroundColor Red
Write-Host " The existing task still points at the previous binary. Run 'cua-driver autostart enable' from an elevated shell to update."
}
}
}

# Unified post-install hints come from a single shared text file so the
Expand Down
26 changes: 26 additions & 0 deletions libs/cua-driver/scripts/install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -1173,6 +1173,32 @@ if ($AutoStart) {
Write-Host " In THIS shell (if already elevated), use: $installedBinary autostart enable"
Write-Host ""
}
} else {
# No -AutoStart, but if a `cua-driver-serve` task is already
# registered, re-register it against the fresh binary. Otherwise
# the task <Command> still points at the previous release dir + an
# older binary that may be missing the hidden-console wrapper (#1654)
# or any later autostart-shape fix.
$prevEAP = $ErrorActionPreference
$ErrorActionPreference = 'Continue'
try {
& schtasks.exe /Query /TN "cua-driver-serve" 2>$null | Out-Null
$hasTask = ($LASTEXITCODE -eq 0)
} finally {
$ErrorActionPreference = $prevEAP
}
if ($hasTask) {
Write-Host ""
Write-Host "Existing 'cua-driver-serve' autostart task detected - re-registering against the fresh binary..." -ForegroundColor Cyan
try {
Register-CuaDriverAutostart -InstalledBinary $installedBinary
Write-Host " Re-registered. Task action now uses this build's hidden-console wrapper." -ForegroundColor Green
}
catch {
Write-Host " Failed to re-register: $($_.Exception.Message)" -ForegroundColor Red
Write-Host " The existing task still points at the previous binary. Run 'cua-driver autostart enable' from an elevated shell to update."
}
}
}

# Unified post-install hints come from a single shared text file so the
Expand Down
Loading