2010-12-07 15 views

Respuesta

7

No existe una variable mágica tal, más probable. Pero es posible obtener esta información:

$me = Get-WmiObject -Query "select * from Win32_Process where Handle=$pid" 
$parent = Get-Process -Id $me.ParentProcessId 
if ($parent.ProcessName -eq 'powershell') { 
    'nested, called from powershell' 
} 
elseif ($parent.ProcessName -eq 'cmd') { 
    'nested, called from cmd' 
} 
else { 
    'not nested' 
} 
+0

Lo suficientemente bueno para mí, gracias! – scobi