我想通过其 ParentProcessID 终止正在运行的进程。我想像您在命令行中一样执行此操作:
wmic process where parentprocessid= 3008 terminate
但现在的问题是,在 PowerShell 中我将 ParentProcessID 作为变量,如下所示:
$p = 3008
现在我想通过变量杀死进程$p
但这不起作用:
wmic process where parentprocessid= $p terminate
如果我将 ParentProcessID 存储在变量中,如何通过其 ParentProcessID 杀死进程?
使用以下命令检索 Win32_Process 对象Get-WmiObject
并将其通过管道传输到Invoke-WmiMethod
调用Terminate
method:
Get-WmiObject Win32_Process -Filter "ParentProcessId=$p" | Invoke-WmiMethod Terminate
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)