QTP 结束进程的几种方法

来源:互联网 发布:中国三明治 知乎 编辑:程序博客网 时间:2024/05/22 02:07

1.

Function KillProcess(ProcessName)
strComputer = "."
Set objWMIService = GetObject("winmgmts://" & strComputer & "/root/cimv2")
Set colProcessList = objWMIService.ExecQuery("Select * from Win32_Process Where Name = '" & ProcessName &"'")
For Each objProcess in colProcessList
objProcess1.Terminate()
Next
End function 


2. 

systemutil.CloseProcessByName "notepad.exe"


3.

Function KillProcess2(processname)
Dim wShell
Set wShell = CreateObject( "WScript.Shell" )
wShell.Exec "TASKKILL /F /IM " & processname
set wShell = nothing
End Function

原创粉丝点击