Forum Discussion

Sunny2's avatar
Sunny2
New Contributor
8 years ago

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

  • Sunny2

     

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

     

     

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

     

    • Sunny2's avatar
      Sunny2
      New Contributor

      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

       

      • prashobkt's avatar
        prashobkt
        Contributor

        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

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