Dim wShell, exec, outStr
Set wShell = CreateObject( "WScript.Shell" )
Set exec = wShell.Exec( "%comspec% /C ping google.com" )
Do While exec.Status = 0
If Not exec.StdOut.AtEndOfStream Then
outStr = exec.StdOut.ReadAll
If exec.ExitCode = 1 then
msgbox "Command failed" & "-" & outStr
End If
Exit Do
End If
If Not exec.StdErr.AtEndOfStream Then
outStr = "STDERR: " & exec.StdErr.ReadAll
msgbox "Command failed" & "-" & outStr
Exit Do
End If
'Wait 1
Loop
***************************************************
Type-2
***************************************************
SystemUtil.Run "cmd.exe","","D:\WINDOWS\system32","open"
window("object class:=ConsoleWindowClass").Type "Dir"
window("object class:=ConsoleWindowClass").Type micReturn
window("object class:=ConsoleWindowClass").Maximize
wait(1)
txt= window("object class:=ConsoleWindowClass").GetvisibleText()
print txt
window("object class:=ConsoleWindowClass").Type "Exit"
window("object class:=ConsoleWindowClass").Type micReturn
Source:http://www.advancedqtp.com/working-with-dos-command-line/
Set wShell = CreateObject( "WScript.Shell" )
Set exec = wShell.Exec( "%comspec% /C ping google.com" )
Do While exec.Status = 0
If Not exec.StdOut.AtEndOfStream Then
outStr = exec.StdOut.ReadAll
If exec.ExitCode = 1 then
msgbox "Command failed" & "-" & outStr
End If
Exit Do
End If
If Not exec.StdErr.AtEndOfStream Then
outStr = "STDERR: " & exec.StdErr.ReadAll
msgbox "Command failed" & "-" & outStr
Exit Do
End If
'Wait 1
Loop
***************************************************
Type-2
***************************************************
SystemUtil.Run "cmd.exe","","D:\WINDOWS\system32","open"
window("object class:=ConsoleWindowClass").Type "Dir"
window("object class:=ConsoleWindowClass").Type micReturn
window("object class:=ConsoleWindowClass").Maximize
wait(1)
txt= window("object class:=ConsoleWindowClass").GetvisibleText()
print txt
window("object class:=ConsoleWindowClass").Type "Exit"
window("object class:=ConsoleWindowClass").Type micReturn
Source:http://www.advancedqtp.com/working-with-dos-command-line/
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.