如何通过VBA代码杀死任务管理器进程? [英] How can I kill task manager processes through VBA code?
本文介绍了如何通过VBA代码杀死任务管理器进程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
谢谢
解决方案
尝试使用此代码,源自 here
Dim oServ As Object
Dim cProc As Variant
Dim oProc As Object
设置oServ = GetObject(winmgmts:)
设置cProc = oServ.ExecQuery(从Win32_Process选择*
对于每个oProc在cProc
'将下面的行中的EXCEL.EXE重命名为你需要终止进程。
'注意:这是'区分大小写
如果oProc.Name =EXCEL.EXE然后
MsgBoxKILL用于显示一个测试信息pur
errReturnCode = oProc.Terminate()
结束如果
下一个
I'm trying to kill certain processes through VBA. I have a proprietary object that connects to a market data bus. Through RTD I call this object to pub/sub to the bus. However sometimes the connection drops and I need to kill the process via task manager. Is there a way to kill a process through VBA?
Thanks
解决方案
Try with this code, sourced from here
Dim oServ As Object
Dim cProc As Variant
Dim oProc As Object
Set oServ = GetObject("winmgmts:")
Set cProc = oServ.ExecQuery("Select * from Win32_Process")
For Each oProc In cProc
'Rename EXCEL.EXE in the line below with the process that you need to Terminate.
'NOTE: It is 'case sensitive
If oProc.Name = "EXCEL.EXE" Then
MsgBox "KILL" ' used to display a message for testing pur
errReturnCode = oProc.Terminate()
End If
Next
这篇关于如何通过VBA代码杀死任务管理器进程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文