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

Discussion in 'Java' started by Chris, Apr 6, 2004.

  1. Chris

    Chris Guest

    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
     
    Chris, Apr 6, 2004
    #1
    1. Advertising

  2. Chris

    Chris Guest

    (Chris) wrote in message news:<>...
    > 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
     
    Chris, Apr 7, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. venkat
    Replies:
    1
    Views:
    374
    Eliyahu Goldin
    Jul 31, 2003
  2. circuit_breaker
    Replies:
    2
    Views:
    2,092
    Jack Jia
    Apr 4, 2004
  3. Rocket Hawk

    error running bat file from ASP page

    Rocket Hawk, Jan 7, 2004, in forum: ASP General
    Replies:
    2
    Views:
    577
    GNS Admin
    Jan 11, 2004
  4. GP
    Replies:
    3
    Views:
    220
  5. Xavier Noëlle
    Replies:
    7
    Views:
    148
    Robert Klemme
    Mar 2, 2011
Loading...

Share This Page