| 1 |
# Copied from GStreamer project |
| 2 |
# Author: Seungha Yang <[email protected]> |
| 3 |
# Xavier Claessens <[email protected]> |
| 4 |
|
| 5 |
$i=1 |
| 6 |
$ppid=$PID |
| 7 |
do { |
| 8 |
$ppid=(Get-CimInstance Win32_Process -Filter "ProcessId=$ppid").parentprocessid |
| 9 |
$pname=(Get-Process -id $ppid).Name |
| 10 |
if($pname -eq "cmd" -Or $pname -eq "powershell" -Or $pname -eq "pwsh") { |
| 11 |
Write-Host ("{0}.exe" -f $pname) |
| 12 |
Break |
| 13 |
} |
| 14 |
# not found yet, find grand parent |
| 15 |
# 10 times iteration seems to be sufficient |
| 16 |
$i++ |
| 17 |
} while ($i -lt 10) |