且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

杀死具有特定名称的所有进程

更新时间:2023-11-30 11:50:22

该错误信息表示 Exec 找不到 pskill.exe,因此很可能是可执行文件不在 %PATH% 或当前工作目录中.您可以通过指定可执行文件的完整路径来缓解这种情况.

The error message means that Exec can't find pskill.exe, so the executable most likely isn't located in the %PATH% or the current working directory. You could mitigate that by specifying the full path to the executable.

但是,查询返回的对象Win32_Process 有一个 Terminate 方法.我建议使用它而不是炮轰:

However, the objects returned from querying Win32_Process have a Terminate method. I'd recommend using that instead of shelling out:

For Each Process in ProcessList
    Process.Terminate
Next