QTP三种打开应用程序的方法(转)

上一篇 / 下一篇  2012-10-23 11:09:28 / 个人分类:功能自动化与QTP

(转自http://blog.163.com/c_y_j/blog/static/1750170542011725114656852/)
1、SystemUtil.Run ' SystemUtil对象的Run方法
SystemUtil.Run "D:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe"

2、InvokeApplication ' 调用程序函数
InvokeApplication "D:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe"

3、WSH ' 通过wsh对象的Run(bat)或者exec(exe)方法
Dim oWSH
Set WSH = CreateObject("WScript.shell")
oWSH.exec "D:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe"
Set WSH = nothing


Dim oWSH
Set WSH = CreateObject("WScript.shell")
oWSH.run " E:\WORK\Projects\3.bat"
Set WSH = nothing

结合ERR对象和on err resume next语句所做的例子:

On Error Resume Next
Dim bFlag
bFlag = CBool(bFlag)
bFlag =systemutil.Run  ("C:\WINDOWS\system32\calc.exe")
MsgBox bFlag
If Err.Number<>0 Then
 MsgBox Err.Description
 Err.Clear
End If


TAG:

 

评分:0

我来说两句

Open Toolbar