4 Replies Latest reply on Mar 4, 2012 11:33 PM by kc@dafolo.dk

    Execute .bat file from LC

    kc@dafolo.dk Level 1

      Hi all,

       

      I have a situation where I need to execute a .bat file from LC. Is that possible and how should I approach this?

      Thanks in advance

       

      Cheers

      Kim Christensen

      Dafolo A/S

        • 1. Re: Execute .bat file from LC
          $Nith$ Level 4

          Use the following syntax to execute the batch file.

           

          Runtime.getRuntime().exec("cmd /c start file.bat");

           

           

          • 2. Re: Execute .bat file from LC
            kc@dafolo.dk Level 1

            Hi Nith,

             

            I tried your suggestion – however it does not work as I expected. The process seems to execute – however nothing of what is in the bat file is done:

             

            E.g. I have this bat file – and when I run it with your suggestion in LC nothing happens – when I run it on the server I get the copy of the file:

             

            I have added the following in my Execute Script service action:

             

            Runtime.getRuntime().exec("cmd /c c:\\file.bat");

             

            The .bat file looks like this:

             

            ECHO OFF

            COPY "C:
            installer_debug.txt" "C:
            new_installer_debug.txt"

            PAUSE

             

            When I run the cmd /c c:\\echoName.bat in the "Run" window on the server it executes as expected, but not when I invoke the Process through Workbench.

             

            What am I doing wrong – do I need to setup something on my server (Systems is: JBoss Turnkey, MySQL,  LC 2.5)?

             

            \Kim

            • 3. Re: Execute .bat file from LC
              $Nith$ Level 4

              Your batch file should be placed in server or in a shared folder where the

              server has access.

              • 4. Re: Execute .bat file from LC
                kc@dafolo.dk Level 1

                Hi again,

                 

                The .bat file is located here: c:\file.bat

                on the server.  When I invoke the process through Workbench nothing happens, but when I execute "cmd /c c:\file.bat" in "Run" on the server then the .bat file is executed.

                 

                Cheers

                Kim Christensen

                Dafolo A/S