fix: capture gateway apply native warnings

This commit is contained in:
Codex
2026-06-26 07:26:54 +00:00
parent 0ee9696923
commit f0d207b420
+24 -9
View File
@@ -1147,11 +1147,25 @@ $EnsureVbs = Join-Path $Root 'ensure-node-ws.vbs'
$RunTask = 'wscript.exe //B //Nologo "' + $RunVbs + '"'
$EnsureTask = 'wscript.exe //B //Nologo "' + $EnsureVbs + '"'
New-Item -ItemType Directory -Force -Path $Root, (Join-Path $Root 'logs'), (Join-Path $Root '.state'), (Join-Path $Root 'tools'), (Join-Path $Root 'tools\\src') | Out-Null
function RunNativeCapture([scriptblock]$Block) {
$previous = $ErrorActionPreference
$ErrorActionPreference = 'Continue'
try {
$output = @(& $Block 2>&1)
$exitCode = $global:LASTEXITCODE
return [pscustomobject]@{
exitCode = [int]$exitCode
output = (($output | ForEach-Object { [string]$_ }) -join "\`n")
}
} finally {
$ErrorActionPreference = $previous
}
}
function EndTaskIfPresent([string]$Name) {
$task = Get-ScheduledTask -TaskName $Name -ErrorAction SilentlyContinue
if ($null -eq $task) { return }
if ([string]$task.State -eq 'Running') {
$null = schtasks /End /TN $Name 2>&1
$null = RunNativeCapture { schtasks /End /TN $Name }
Start-Sleep -Seconds 2
}
}
@@ -1176,14 +1190,14 @@ foreach ($proc in $processes) {
$written = @()
foreach ($item in @($payload.sourceFiles)) { $written += WritePayloadFile $item }
foreach ($item in @($payload.runnerFiles)) { $written += WritePayloadFile $item }
$runCreate = schtasks /Create /TN $TaskName /SC ONCE /ST 00:00 /TR $RunTask /F 2>&1
if ($LASTEXITCODE -ne 0) { throw "run task create failed: $runCreate" }
$periodicCreate = schtasks /Create /TN $PeriodicTaskName /SC MINUTE /MO 5 /TR $EnsureTask /F 2>&1
if ($LASTEXITCODE -ne 0) { throw "periodic task create failed: $periodicCreate" }
$runKey = reg add HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Run /v $RunKeyName /t REG_SZ /d $EnsureTask /f 2>&1
if ($LASTEXITCODE -ne 0) { throw "HKCU Run update failed: $runKey" }
$runOut = schtasks /Run /TN $TaskName 2>&1
$runExit = $LASTEXITCODE
$runCreate = RunNativeCapture { schtasks /Create /TN $TaskName /SC ONCE /ST 00:00 /TR $RunTask /F }
if ($runCreate.exitCode -ne 0) { throw "run task create failed: $($runCreate.output)" }
$periodicCreate = RunNativeCapture { schtasks /Create /TN $PeriodicTaskName /SC MINUTE /MO 5 /TR $EnsureTask /F }
if ($periodicCreate.exitCode -ne 0) { throw "periodic task create failed: $($periodicCreate.output)" }
$runKey = RunNativeCapture { reg add HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Run /v $RunKeyName /t REG_SZ /d $EnsureTask /f }
if ($runKey.exitCode -ne 0) { throw "HKCU Run update failed: $($runKey.output)" }
$runOut = RunNativeCapture { schtasks /Run /TN $TaskName }
$runExit = $runOut.exitCode
Start-Sleep -Seconds 3
$expected = @(Get-CimInstance Win32_Process -Filter "Name='bun.exe'" | Where-Object { ($_.CommandLine -match 'hwpod-node\\.ts\\s+connect') -and ($_.CommandLine -match [regex]::Escape($NodeId)) -and ($_.CommandLine -match [regex]::Escape($CloudUrl)) -and ($_.CommandLine -match [regex]::Escape($WsUrl)) })
$result = [ordered]@{
@@ -1194,6 +1208,7 @@ $result = [ordered]@{
taskName = $TaskName
periodicTaskName = $PeriodicTaskName
runTaskExitCode = $runExit
failureDetail = $(if (($runExit -eq 0) -and ($expected.Count -gt 0)) { $null } else { "runOutput=$($runOut.output)" })
valuesRedacted = $true
}
$result | ConvertTo-Json -Compress -Depth 8