Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Question regarding comspec
#1
Solved: 11 Years, 4 Months ago
Hi,

I am using comspec to run a command line utility.
the algo of my code is something like this

1) capture the current time
2) run the command line utility.
3) capture the current time
4) find the difference between two time - this gives the time taken for the command line utility to complete.

Problem:

QTP is not waiting for the command line utility to finish, the flow moves on to the next line.
Is there anyway how we can make QTP wait till the command line utility completed and then move to the next line for execution???

I am using QTP 9.2

Reply
#2
Solved: 11 Years, 4 Months ago
The Run function of a WScript.Shell object will give you the behavior you want.

References:

http://msdn.microsoft.com/en-us/library/...85%29.aspx

http://www.computerhope.com/cmd.htm

Code:
Dim wsh: Set wsh = CreateObject("WScript.Shell")

'Substitute the command to launch your command line utility here -->
Dim strCommand: strCommand = "ping google.com"

wsh.Run "cmd /c " & strCommand, 10, True

/c = terminate when the program returns
10 = show window based on QTP's window state
True = wait for the program to return before proceeding

You can also do multiple commands joining them with "&" in the command string in case you have to change directories before running your utility. (See the example in the MSDN link above)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)