Results 1 to 2 of 2

Thread: Batch Executing

  1. #1
    sokolramaj is offline Member
    Join Date
    Apr 2009
    Posts
    1
    Rep Power
    0

    Default Batch Executing

    hi i have written this code to execute a batch file in windows 2003 server R2
    but it does not execute anything. it opens the cmd.exe window and does nothing also
    the "Exit Value" and "Return Code" is 0.
    can anyone help me about this?
    is there any windows registry setting to restrict the execution of batch files programatically?

    Thank you!!!!

    Java Code:
    try
    {
    Runtime runtime = Runtime.getRuntime();
    Process process = null;
    try
    {
    System.out.println( "Running: " + fName + ".bat " );
    process = runtime.exec( "cmd /c start " + fName + ".bat" );
    
    int returnCode = process.waitFor();
    System.out.println("Exit value " + process.exitValue());
    System.out.println("Return code value " + returnCode);
    System.out.println("Finished running the SQL Loader script's process. " + " Exit Value = " + ( returnCode == 0? "Success" : "Failure" ) );
    }
    catch ( Exception e )
    {
    System.out.println(e.getMessage());
    e.printStackTrace();
    }
    
    }
    catch ( Exception e )
    {
    System.out.println( "Error running the sqlldr script: " + e );
    e.printStackTrace();
    }

  2. #2
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,429
    Rep Power
    7

    Default

    Did you read this article:
    javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html ?

Similar Threads

  1. Batch Files in java
    By coco in forum New To Java
    Replies: 3
    Last Post: 12-05-2008, 02:30 PM
  2. eclipse batch file
    By doug99 in forum Eclipse
    Replies: 6
    Last Post: 04-24-2008, 03:59 PM
  3. Problem in batch file
    By marwa in forum New To Java
    Replies: 0
    Last Post: 08-14-2007, 11:24 AM
  4. Executing Batch
    By zcoarens in forum New To Java
    Replies: 0
    Last Post: 08-14-2007, 10:49 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •