gstreamer/data/misc/cmd_or_ps.ps1
Seungha Yang 12fdf93ba4 gst-env: Add support for PowerShell 7
The executable binary name of "PowerShell 7" is "pwsh.exe"
which is different from system default installed
"Windows PowerShell (version 5.x or older)"

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2545>
2022-06-03 18:55:36 +00:00

19 lines
489 B
PowerShell

$i=1
$ppid=(gwmi win32_process -Filter "processid='$pid'").parentprocessid
$pname=(Get-Process -id $ppid).Name
While($true) {
if($pname -eq "cmd" -Or $pname -eq "powershell" -Or $pname -eq "pwsh") {
Write-Host ("{0}.exe" -f $pname)
Break
}
# 10 times iteration seems to be sufficient
if($i -gt 10) {
Break
}
# not found yet, find grand parant
$ppid=(gwmi win32_process -Filter "processid='$ppid'").parentprocessid
$pname=(Get-Process -id $ppid).Name
$i++
}