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