Files
hyperframes/packages/cli/src/utils/processes.ps1
T
Miguel Ángel b930c4d2d7 fix(cli): Windows Chrome cleanup and process reads no longer pass PowerShell command text (#8085)
* fix(cli): Windows process reads and Chrome cleanup no longer pass PowerShell command text

* fix(cli): a forced Chrome close on Windows ends what Chrome started

* test(cli): the forced-close test's child holds no pipe to the browser

* test(cli): the forced-close test's child outlives a dead parent, as Chrome's do

* test(cli): forced-close test waits for the kill; PowerShell starts only via processReadArgs

* fix(cli): Windows cleanup ends only a process the CLI started, never a pid it was handed
2026-11-17 20:27:58 +00:00

21 lines
1.0 KiB
PowerShell

# The CLI's reads of Windows' process table and a file's version (utils/windowsProcesses.ts), run with -File; nothing
# a call passes is run as code. identity <id>: its start as a FILETIME. parent <id>: its parent's id.
# table: `id parent start name` lines. version <path>: the file's product version.
param([ValidateSet('identity', 'parent', 'table', 'version')][string]$Read, [string]$Target = '')
$ErrorActionPreference = 'SilentlyContinue'
function Find-Process([string]$Id) {
if ($Id -match '^\d+$') { Get-CimInstance Win32_Process -Filter "ProcessId=$([int]$Id)" }
}
switch ($Read) {
'identity' { $process = Find-Process $Target; if ($process) { $process.CreationDate.ToFileTimeUtc() } }
'parent' { $process = Find-Process $Target; if ($process) { $process.ParentProcessId } }
'table' {
Get-CimInstance Win32_Process | ForEach-Object {
'{0} {1} {2} {3}' -f $_.ProcessId, $_.ParentProcessId, $_.CreationDate.ToFileTimeUtc(), $_.Name
}
}
'version' { if ($Target) { (Get-Item -LiteralPath $Target).VersionInfo.ProductVersion } }
}