【发布时间】:2015-11-24 10:31:39
【问题描述】:
我想通过 ParentProcessID 杀死一个正在运行的进程。我想像你在命令行中那样做:
wmic process where parentprocessid= 3008 terminate
但现在问题是,在 PowerShell 中,我将 ParentProcessID 作为一个变量,如下所示:
$p = 3008
现在我想通过变量 $p 终止进程,但这不起作用:
wmic process where parentprocessid= $p terminate
如果我将 ParentProcessID 存储在变量中,我如何通过其 ParentProcessID 终止进程?
【问题讨论】:
-
嗨,你为什么不使用
Get-Process?你绝对应该使用 wmic? -
wmic process where parentprocessid=$p terminate -
@kekimian -
Get-Process不会为您提供有关父进程的信息 -
@Matt 标记编辑将允许您在同一编辑中仅更改标题/正文中的一个字符 :)
-
@MathiasR.Jessen 我知道。当有其他事情要做时,我不喜欢进行小片段编辑。也不在乎和OP打架就可以了。
标签: powershell wmi wmic