merge: bound HWPOD desktop apply probes

This commit is contained in:
pikastech
2026-07-21 10:34:14 +02:00
+13 -7
View File
@@ -609,14 +609,20 @@ $versionOut = @(& $probe @launcherArgs -c "import sys;import tkinter;print(sys.v
if ($LASTEXITCODE -ne 0 -or (($versionOut -join "\`n") -notlike "*$($payload.expectedVersionPrefix)*")) { throw "Python version mismatch: $($versionOut -join ' | ')" } if ($LASTEXITCODE -ne 0 -or (($versionOut -join "\`n") -notlike "*$($payload.expectedVersionPrefix)*")) { throw "Python version mismatch: $($versionOut -join ' | ')" }
New-Item -ItemType Directory -Force -Path $root, (Split-Path -Parent $configPath), (Split-Path -Parent $credentialPath), (Split-Path -Parent $logPath) | Out-Null New-Item -ItemType Directory -Force -Path $root, (Split-Path -Parent $configPath), (Split-Path -Parent $credentialPath), (Split-Path -Parent $logPath) | Out-Null
$legacyStopped = @() $legacyStopped = @()
$legacyTasksStillEnabled = @()
foreach ($taskName in $legacyTaskNames) { foreach ($taskName in $legacyTaskNames) {
Stop-ScheduledTask -TaskName $taskName -ErrorAction SilentlyContinue $null = & schtasks.exe /Query /TN $taskName 2>$null
Disable-ScheduledTask -TaskName $taskName -ErrorAction SilentlyContinue | Out-Null if ($LASTEXITCODE -eq 0) {
$null = & schtasks.exe /End /TN $taskName 2>$null
$null = & schtasks.exe /Change /TN $taskName /Disable 2>$null
if ($LASTEXITCODE -ne 0) { $legacyTasksStillEnabled += $taskName }
}
} }
foreach ($runKey in $legacyRunKeyNames) { foreach ($runKey in $legacyRunKeyNames) {
Remove-ItemProperty -Path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Run' -Name $runKey -ErrorAction SilentlyContinue Remove-ItemProperty -Path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Run' -Name $runKey -ErrorAction SilentlyContinue
} }
$legacy = @(Get-CimInstance Win32_Process | Where-Object { $allBefore = @(Get-CimInstance Win32_Process)
$legacy = @($allBefore | Where-Object {
$commandLine = [string]$_.CommandLine $commandLine = [string]$_.CommandLine
$legacyProcessPatterns | Where-Object { $commandLine.Contains($_) } | Select-Object -First 1 $legacyProcessPatterns | Where-Object { $commandLine.Contains($_) } | Select-Object -First 1
}) })
@@ -625,7 +631,7 @@ foreach ($proc in $legacy) {
$legacyStopped += [int]$proc.ProcessId $legacyStopped += [int]$proc.ProcessId
} }
Start-Sleep -Milliseconds 500 Start-Sleep -Milliseconds 500
$old = @(Get-CimInstance Win32_Process | Where-Object { $_.CommandLine -and $_.CommandLine.Contains($scriptPath) }) $old = @($allBefore | Where-Object { $_.CommandLine -and $_.CommandLine.Contains($scriptPath) })
foreach ($proc in $old) { Stop-Process -Id $proc.ProcessId -Force -ErrorAction SilentlyContinue } foreach ($proc in $old) { Stop-Process -Id $proc.ProcessId -Force -ErrorAction SilentlyContinue }
Start-Sleep -Milliseconds 500 Start-Sleep -Milliseconds 500
[IO.File]::WriteAllBytes($scriptPath, [Convert]::FromBase64String([string]$payload.artifactBase64)) [IO.File]::WriteAllBytes($scriptPath, [Convert]::FromBase64String([string]$payload.artifactBase64))
@@ -644,11 +650,11 @@ $stdoutPath = $logPath + '.stdout'
$stderrPath = $logPath + '.stderr' $stderrPath = $logPath + '.stderr'
Start-Process -FilePath $gui -ArgumentList @($launcherArgs + @($scriptPath)) -WorkingDirectory $root -RedirectStandardOutput $stdoutPath -RedirectStandardError $stderrPath Start-Process -FilePath $gui -ArgumentList @($launcherArgs + @($scriptPath)) -WorkingDirectory $root -RedirectStandardOutput $stdoutPath -RedirectStandardError $stderrPath
Start-Sleep -Seconds 3 Start-Sleep -Seconds 3
$processes = @(Get-CimInstance Win32_Process | Where-Object { $_.Name -like 'python*.exe' -and $_.CommandLine -and $_.CommandLine.Contains($scriptPath) }) $allAfter = @(Get-CimInstance Win32_Process)
$processes = @($allAfter | Where-Object { $_.Name -like 'python*.exe' -and $_.CommandLine -and $_.CommandLine.Contains($scriptPath) })
$explorerSessions = @(Get-Process explorer -ErrorAction SilentlyContinue | Select-Object -ExpandProperty SessionId -Unique) $explorerSessions = @(Get-Process explorer -ErrorAction SilentlyContinue | Select-Object -ExpandProperty SessionId -Unique)
$interactive = @($processes | Where-Object { $explorerSessions -contains $_.SessionId }) $interactive = @($processes | Where-Object { $explorerSessions -contains $_.SessionId })
$legacyTasksStillEnabled = @($legacyTaskNames | Where-Object { $task = Get-ScheduledTask -TaskName $_ -ErrorAction SilentlyContinue; $task -and $task.Settings.Enabled }) $legacyProcessesRemaining = @($allAfter | Where-Object {
$legacyProcessesRemaining = @(Get-CimInstance Win32_Process | Where-Object {
$commandLine = [string]$_.CommandLine $commandLine = [string]$_.CommandLine
$legacyProcessPatterns | Where-Object { $commandLine.Contains($_) } | Select-Object -First 1 $legacyProcessPatterns | Where-Object { $commandLine.Contains($_) } | Select-Object -First 1
}) })