QTP对cmd操作

上一篇 / 下一篇  2008-11-26 17:47:28 / 个人分类:QTP

'运行CMD
SystemUtil.Run "cmd.exe","","C:\WINDOWS\system32","open"
'输入 ping 51testing.com 字段
Window( "object class:=ConsoleWindowClass" ).Type "Ping 51testing.com"
'输入回车
Window( "object class:=ConsoleWindowClass" ).Type micreturn
'获得CMD里面的内容
txt = Window( "object class:=ConsoleWindowClass" ).GetVisibleText()
'在LOG打印出CMD里面的内容
print txt

使用WshShell 对象

Dim wShell, exec
Set wShell = CreateObject( "Wscrīpt.Shell" )
'"%comspec% 是CMD的环境变量名称
Set exec = wShell.Exec( "%comspec% /C ping 51testing.com" )
print exec.StdOut.ReadAll


TAG: QTP

 

评分:0

我来说两句

日历

« 2024-05-01  
   1234
567891011
12131415161718
19202122232425
262728293031 

数据统计

  • 访问量: 47890
  • 日志数: 80
  • 建立时间: 2008-10-27
  • 更新时间: 2009-07-17

RSS订阅

Open Toolbar