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

Community Tip - Learn all about PTC Community Badges. Engage with PTC and see how many you can earn! X

How to run .bat file in trigger scripting of Integrity

vbabu-4
4-Participant

How to run .bat file in trigger scripting of Integrity

How to run a batch file in trigger script of Integrity?

java.lang.Runtime.getRuntime().exec('cmd /c start E:\\oval\\CPProject.bat');

is above command is right to execute batch using JAVA API in Integrity server.

I am able to write and read batch file using JAVA API script but above command does not execute the batch file after writing. Kindly help me to execute the batch file in Integrity server. 

Thanks in advance

1 ACCEPTED SOLUTION

Accepted Solutions

When doing something similar I think I had to specify the complete path to "cmd". Here is a code snippet I used:

var exec = "C:\\Windows\\System32\\cmd.exe /C C:\\Progra~1\\Integrity\\IntegrityServer10\\data\\triggers\\scripts\\batchFile.bat";

var r = java.lang.Runtime.getRuntime();

var p1 = r.exec(exec);

var returnCode = p1.waitFor();

View solution in original post

3 REPLIES 3

When doing something similar I think I had to specify the complete path to "cmd". Here is a code snippet I used:

var exec = "C:\\Windows\\System32\\cmd.exe /C C:\\Progra~1\\Integrity\\IntegrityServer10\\data\\triggers\\scripts\\batchFile.bat";

var r = java.lang.Runtime.getRuntime();

var p1 = r.exec(exec);

var returnCode = p1.waitFor();

vbabu-4
4-Participant
(To:bbauer-2)

Thanks a lot it works for me 🙂

mrump
14-Alexandrite
(To:vbabu-4)

Please keep in mind, that any process you start inside a trigger context is/might be "blocking" the trigger and therefore your entire server for all other users.

If you do not detach the severtrigger and yout batch operations it can lead to serious performance issues.

detach a long running process from the trigger context that started it

Top Tags