我必须杀死一个没有独特名称的进程(一个 exe 文件)。我所知道的是其名称的前两个字符,例如“3D”。
如何找到进程名称并杀死它。
这是我的代码,我在其中检查进程是否正在运行,但是然后呢?我尝试使用通配符,但它不起作用。
选项1:
'-- get a collection of processes running
Dim nameProcess() As System.Diagnostics.Process = System.Diagnostics.Process.GetProcesses
For Each p As Process In Process.GetProcesses()
Debug.WriteLine(p.ProcessName)
Next
' this is the process check function
threeD = 3D 'I have declared this as string before in the code
If IsProcessRunning(threeD) = True Then
MsgBox("3D Found")
End If
选项 2:
Dim proc() As Process = Process.GetProcessesByName("3D*")
For Each temp As Process In proc
temp.Kill()
Next