0

Can I capture text from the command prompt in UFT? How could I capture text from the command prompt in UFT for validation purposes?

1 Answers1

1

You can use the StdOut property of the Exec object to read text from the command window:

Set objShell = CreateObject("WScript.Shell")
sCommand = "ping 127.0.0.1"
Set objExecObject = objShell.Exec("cmd /c " & sCommand)

Do While Not objExecObject.StdOut.AtEndOfStream
    sText = objExecObject.StdOut.ReadLine()
Loop

Replace the command text with your command, exactly how you would type it in the command prompt.

Take a look at extra examples in these questions:

Get output from command line in VB6

Run Command Line & Command From VBS

Étienne Laneville
  • 4,697
  • 5
  • 13
  • 29