QTP_QTP操作CMD

'运行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


你可能感兴趣的:(c,windows,object,cmd,System,Class)