问候,
我有以下 VBScript:
Option Explicit
Dim objWMIService, objProcess, colProcess
Dim strComputer, strList
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")
Set colProcess = objWMIService.ExecQuery _
("Select * from Win32_Process")
For Each objProcess in colProcess
MsgBox(objProcess.ExecutablePath)
'If InStr(objProcess.ExecutablePath, "EASE") <> 0 Then
' MsgBox("TERMINATING")
' objProcess.Terminate()
'End If
Next
出于某种原因,我在 MsgBox(objProcess.ExecutablePath) 行出现错误。它说“无效使用 Null:'ExecutablePath'”。奇怪的是,当我取消注释注释行并注释掉问题行时,我没有收到此错误。
如您所见,我正在尝试终止具有特定路径名的所有进程,但似乎字符串匹配不起作用,就像可执行路径有问题一样。