Running a bat file from a Tomcat servlet using the exec command

C

Chris

I cannot get a Tomcat servlet to execute a Windows Bat file.
Is there a particular setting in the catalina.policy file that I need
to change?
Here is a code snippet of the call:

Runtime load = Runtime.getRuntime();
Process process = load.exec("cmd.exe /c start copyFiles.bat", null,
new File("C:\\Tomcat 5.0\\webapps\\myApp\\files"));

Thanks for any help.

-Chris
 
C

Chris

I cannot get a Tomcat servlet to execute a Windows Bat file.
Is there a particular setting in the catalina.policy file that I need
to change?
Here is a code snippet of the call:

Runtime load = Runtime.getRuntime();
Process process = load.exec("cmd.exe /c start copyFiles.bat", null,
new File("C:\\Tomcat 5.0\\webapps\\myApp\\files"));

Thanks for any help.

-Chris

OK, I have got it working.
I needed to add some entries to the catalina.policy file to set
execute permissions on
java.lang.RuntimePermission
java.lang.Win32Process

I'm not sure if they are both needed.
-Chris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top