Reputation: 278
I'm making a utility using QuickTest Professional which calls a batch file with some parameters.
This batch file further calls a vbscript and passes some parameters to this vbs file.
This vbs file perform operations and generate a number.
I want this number to flow back from vbs to batch and then to QTP.
This is what I've figured out so far:
QTP(sending parameters to bat) >> Batch(sending parameters to vbs) >> VBS (generates a number)
now I want this vbs to return the output number back
VBS >> Batch(same bat which called vbs file) >> QTP(same qtp process which called this batch)
Here is my code:
QTP: (calling batch)
Dim BatchRun
Set BatchRun = CreateObject ("WSCript.shell")
invokefile= Chr(34) + "C:/invokebugz.bat" + Chr(34)
BatchRun.Run invokebugzfile & lob & " " & mailto & " " & mailcc & " " & title & " " & subject
Bat: (calling vbs)
cd C:\
cscript abc.vbs "%~1" "%~2" "%~3" "%~4" "%~5"
vbs:
Set args = Wscript.Arguments ' to accept command line arguments
xprod = args(0)
mailto = args(1)
mailcc = args(2)
xtitle = args(3)
xcomment = args(4)
Upvotes: 0
Views: 1941
Reputation: 63481
You can get the value back if you just print it to standard output. So just write the result from VBS like this:
Wscript.Echo result
The for
command can be used to get the output of a command that you invoke:
for /f %%a in ('cscript abc.vbs "%~1" "%~2" "%~3" "%~4" "%~5"') do (
echo The output is %%a
)
If the output is just a number, you shouldn't need to add any extra options to the for loop. Try running for /?
for more help.
Upvotes: 2