51Testing软件测试论坛

标题: WSCript.shell.run调用CMD,出错问题,解决办法!! [打印本页]

作者: gutifeng    时间: 2012-4-26 11:15
标题: WSCript.shell.run调用CMD,出错问题,解决办法!!
问题源代码如下:
Dim aaa
aaa="C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe"
Set oShell = CreateObject("WSCript.Shell")
oShell.Run aaa,2,true
Set oShell = Nothing

参照QTP的HELP:Run Method的用法

解决后代码如下:
Dim oShell
Dim a
'C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe
a="cmd /K CD C:\Program Files\HP\QuickTest Professional\samples\flight\app\ & flight4a.exe"
Set oShell = CreateObject ("WSCript.shell")
oShell.run   a
Set oShell = Nothing

出现新问题:CMD窗口无法自动关闭
解决办法:oShell.run   a,0 (查看任务管理器,cmd.exe进程关闭)
作者: snakeshiy    时间: 2012-4-26 17:44
写成这样试试
a = "cmd /c CD XXX"




欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) Powered by Discuz! X3.2