Ask a Question

How to run a bat file which is present in some other location on the Computer

Sunny2
New Contributor

How to run a bat file which is present in some other location on the Computer

 Hi 

 

I have a set of test cases that I need to run for every execution. To receive valid responses, I need to tunnel to the ports using a bat file which I need to open manually each and every time

 

Is there any way I can open the bat file using Groovy Script before I start the execution in SOAP UI?

 

Thanks

Sunny

 

3 REPLIES 3
prashobkt
Contributor

Re: How to run a bat file which is present in some other location on the Computer

@Sunny2

 

Try the below code, do not use pause statement in BAT file.

 

 

def cmd = "sample.bat"
def process = "$cmd".execute();
process.waitFor();

 

/T3D
Sunny2
New Contributor

Re: How to run a bat file which is present in some other location on the Computer

Thanks @prashobkt

 

I tried to execute the code

As my file is in an external folder which is something like "C:/XXX/XXXX/file.bat", I included the same in the script as follows 

 

def cmd = "C:/XXX/XXXX/file.bat"
def process = "$cmd".execute();
process.waitFor();

 

When this script is run, I got a dialog box something like Script-result:1 (screenshot attached) . However I couldn't see that file is opened.

 

Can you please help me if you have any idea on this?

 

Thanks

Sunny

2016-08-25 15_20_36-Clipboard.png

 

prashobkt
Contributor

Re: How to run a bat file which is present in some other location on the Computer

@Sunny2

 

As per my knowledge

 

Script-Result-1 is failure and 0 is success.

 

If you are providing any file as input in .batfile , please use absolute path. The .bat files are command line tools and are processed in Background so you cannot see any window.

 

Below is the batfile I used to test.

 

=============my.bat================

@echo off
echo This is a test
Mkdir d:\rt

==================================

 

 

/T3D
cancel
Showing results for 
Search instead for 
Did you mean: