Ask a Question

How to write a script to call a bat file to run?

SOLVED
heidi_n
Regular Contributor

How to write a script to call a bat file to run?

I would like to have a script (JavaScript) that runs a bat file. How would I go about doing this?

 

The bat file is located in C:\P4\testcomplete\branch_dev\WebIQ_Scripts\Clear_User_Settings and is called Clear_WebIQ_User_Settings.bat 

 

bat_file.png

Thank you, Heidi / Quality Assurance Specialist
8 REPLIES 8
heidi_n
Regular Contributor

Basically, I want to run this bat file before I run any of my normal TC scripts for my web app. I have all my web app scripts ready, but I'm not sure how to launch the bat file/make it run at the beginning of my test.

Thank you, Heidi / Quality Assurance Specialist

Hi,

 

You can add your .bat to TestedApps and then call it:

 

TestedApps.yourBatFile.Run()

Hi Heidi,

 

> how to launch the bat file/make it run at the beginning of my test.

Consider to execute your .bat file from OnStartTest event handler.

 

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================
tristaanogre
Esteemed Contributor

Or, even another option, use the WshShell.Exec method to execute a command line of any type, including executing a batch file.


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
heidi_n
Regular Contributor

But non keyword tests don't have the Tested Apps section, right? We are not using keyword tests.

Thank you, Heidi / Quality Assurance Specialist
tristaanogre
Esteemed Contributor

The "TestedApps" object can be added to any project and called by either KeywordTests or Script code.


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
heidi_n
Regular Contributor

I added the bat file as a Tested App. How would I call it to run in a script (JavaScript)?

 

EDIT: Oops, I see from an earlier comment it is 

TestedApps.yourBatFile.Run()

I will try that thanks everyone! 

Thank you, Heidi / Quality Assurance Specialist
cancel
Showing results for 
Search instead for 
Did you mean: