2021-10-01 06:03:23 +08:00
|
|
|
# Copied from GStreamer project
|
2021-02-21 01:04:01 +08:00
|
|
|
# Author: Seungha Yang <seungha.yang@navercorp.com>
|
2022-09-18 21:33:20 +08:00
|
|
|
# Xavier Claessens <xclaesse@gmail.com>
|
2021-02-21 01:04:01 +08:00
|
|
|
|
|
|
|
$i=1
|
2022-09-18 21:33:20 +08:00
|
|
|
$ppid=$PID
|
|
|
|
do {
|
|
|
|
$ppid=(Get-CimInstance Win32_Process -Filter "ProcessId=$ppid").parentprocessid
|
|
|
|
$pname=(Get-Process -id $ppid).Name
|
2022-06-15 05:59:33 +08:00
|
|
|
if($pname -eq "cmd" -Or $pname -eq "powershell" -Or $pname -eq "pwsh") {
|
2021-02-21 01:04:01 +08:00
|
|
|
Write-Host ("{0}.exe" -f $pname)
|
|
|
|
Break
|
|
|
|
}
|
2022-09-18 21:33:20 +08:00
|
|
|
# not found yet, find grand parent
|
2021-02-21 01:04:01 +08:00
|
|
|
# 10 times iteration seems to be sufficient
|
|
|
|
$i++
|
2022-09-18 21:33:20 +08:00
|
|
|
} while ($i -lt 10)
|