Forum Discussion

ssv's avatar
Occasional Contributor
6 years ago

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?

2 Replies

  • cunderw's avatar
    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. 

  • tristaanogre's avatar
    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