Ask a Question

Test Complete Batch Files excution results printed out within Test Complete Project

Occasional Contributor

Test Complete Batch Files excution results printed out within Test Complete Project

We have a project where we use batch files to perform the operations. 


For Example, like starting an external server, installing programs silently.


We start the batch file, through 

wshShell.Run(fullPath, 1, true)


We have seen instabilities where we had failures in installation or starting the server, so We thought it would be good, if we could print out the outputs from the batch files to the test complete log messages.


This would save us a lot of debug time.


Has anyone worked on a similar issue like this?

Esteemed Contributor

Running batches using WshShell does not return an output from the console.  The "Run" method simply returns any integer error code returned from the command being executed.


Something to consider for testing purposes.  In the command for your WshShell.Run, you can "pipe" the output to a file (I used to do this mumble-mumble years ago when I was working in MS-DOS 6.22).  Then, you can read the contents of the file using an aqFile method and verify the contents that way.


The following function (written in JavaScript) will redirect the output of the indicated batch file into the indicated file in what is configured as the "current directory".


function blah(){
    WshShell.CurrentDirectory = Project.Path + '\\Script\\';
    WshShell.Exec(Project.Path + '\\Script\\testfile.bat > test.txt');

Note I'm using Exec instead of Run but the same will work for Run

Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
Community Hero

I could be wrong but I don't think you can directly get output from wshShell, but what you could do it modify your batch files to write logs to known location and then read those files back into Test Complete to log their output. Or even just attach the full file to the log. 


Click the Accept as Solution button if my answer has helped
Showing results for 
Search instead for 
Did you mean: