Run a bat file from a java flow

Hi all!

Is there anyone out there who knows how you run a .bat file from an IS flow. I dont mind to code if thats neccasery.
The task is to make a flow that runs a .bat file that maps a server when its called.


Try writing a java service with the following code:

}catch(Exception e){}

Thanks for your answers!

I tryed the first example but I get a strange error.
C:\IntegrationServer4\webMethods\IntegrationServer4\packages\Utils\code\source\ illegal escape character
1 error
(The ^ sign is under the ; character)

Do you have a qlue of what this means


Use / instead of ; or, even better, use

Correct it as below:


(Note the two backward slashes.)

But it is better to create the string using File.separator so that your code will be portable across different operating systems.

Runtime.getRuntime().exec(“c:” + + “map.bat”);

Hi all!

I got it to work with

}catch(Exception e){}

Thanks for all answers.


Your Java service would be more robust if it waited for the background process to finish and ensured that an int code of 0 was returned.
You current java service will act the same way, regardless of whether or not your .bat file executed successfully.

i need to execute a bat file with parameters
does anyone knows how do i do that?

You can use fireCommandExec service found in WmSamples package. First call pub.string:messageFormat service and pass the value to pattern in serciceIn as “yourBatchfile.bat {0}” where 0 is the argument you want to pass. You can pass more than one argument by adding {1}, {2} as so forth. Then call fireCommandExec service and pass the final value to fullCommand you got from messageFormat.


Thanks NN!!!