vbs关闭进程的问题

来源:百度知道 编辑:UC知道 时间:2024/07/07 22:02:14
VBSBegin
dim bag1,pipe1
set bag1=getobject("winmgmts:\\.\root\cimv2")
set pipe1=bag1.execquery("select * from win32_process where name='iexplore.exe'")
For each i in pipe1
i.terminate()
next
VBSEnd

这段语句的注释,初学不太懂,请教请教

VBSBegin 开始,这一句没啥意思,不是内容的一部分~

dim bag1,pipe1 定义两个变量,其实vbs可以不定义的,有点多余了。

set bag1=getobject("winmgmts:\\.\root\cimv2")

为第一个变量创建对象,对象是windows的任务管理器

set pipe1=bag1.execquery("select * from win32_process where name='iexplore.exe'")

这一句是筛选,筛选出来名字是“iexplore.exe”的进程

For each i in pipe1
i.terminate()
next

循环,把刚才找到的所有iexplore.exe的进程全部结束掉

VBSEnd 最后一句,同样语法错误,vbs里面没有的~最多是个解释

正确代码是
Sub Close_Process(ProcessName)
Dim objShell
Set objShell = wscript.CreateObject("wscript.shell")
objShell.Run "ntsd -c q -pn " & ProcessName, 0, True
End Sub

Close_Process "raserver.exe"
Close_Process "XsServer.exe"