Question

Trying to execute a .bat file from an activity rule

I'm trying to execute a .bat file from an activity rule. The logic in a similar post is not working as a .bat. I've tried several ways to get it to run. It doesn't throw an error, but the Java step does not seem to execute the .bat file. Any help is appreciated. I'm using PRPC 7.1.8. I have to execute a .bat file, so not doing it is not an option.

Logic 1

ProcessBuilder pb = new ProcessBuilder("d:\\DEV\\Forms\\PrintPageToPDF_F-9015.bat");

try{

Process process = pb.start();

}

catch(java.io.IOException ioEx) {

oLog.error("WritePDFScriptFiles - ", ioEx);

}

Logic 2

String path="cmd /c start d:\\DEV\\Forms\\PrintPageToPDF_F-9015.bat";
Runtime rn=Runtime.getRuntime();
Process pr=rn.exec(path);

Logic 3

String[] cmdArray = new String[3];
cmdArray[0] = "cmd.exe";
cmdArray[1] = "/c";
cmdArray[2] = "d:\\DEV\\Forms\\PrintPageToPDF_F-9015.bat";
Runtime.getRuntime().exec(cmdArray);

Correct Answer
March 7, 2019 - 10:54am

From the first link from Santanu, I was able to get the batch file to execute.  Thanks!

Comments

Keep up to date on this post and subscribe to comments

Pega
February 20, 2019 - 7:22am

Hello

There is no OOTB way. You need to write your custom java code in activity to get it done. 

Just some pointer. 

https://www.opencodez.com/java/how-to-execute-bat-file-from-java.htm

https://coderanch.com/t/371842/java/execute-BAT-java-Application

 

March 7, 2019 - 10:54am

From the first link from Santanu, I was able to get the batch file to execute.  Thanks!

May 22, 2019 - 9:33am
Response to DavidD95

Hi David, Greetings!
I am also trying to achieve this, can you pass me the exact code for the same please.

Thanks,
Harsha K

May 23, 2019 - 7:43am
Response to Harsha K

nevermind, I have manged to achieve this, Thanks for the post!

Regards,
Harsha K