- strComputer="."
- Set wmi = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
- Set Get_Process=wmi.instancesof("win32_process")
-
-
- For Each Process In Get_Process
- count=count+1
- ReDim Preserve Array_Name(count-1)
- Array_Name(count-1)=Process.name
- Next
-
- Input= InputBox("请输入要结束的进程名称:")
-
- For i=0 To count
- ReDim Preserve Array_Name(count)
- If Input=Array_Name(i) Then
- Set New_Process = wmi.execquery("select * from win32_process where name ="& Array_Name(i) )
- For Each Over_Process In New_Process
- Over_Process.terminate()
- Next
- Set New_Process = Nothing
- Set Over_Process= Nothing
- End If
- Next
-
- Set wmi = Nothing
- Set Get_Process = Nothing
- Set Process = Nothing
复制代码
报错是在上面的第18行
代码的目的是,想实现用inputbox输入一个进程的名字,例如输入taskmgr.exe ,然后结束它。 |