Java Run batch file issue on windows server 2003 versus windows server 2008-Collection of common programming errors


  • bernie

    Using java’s “runtime.exec” i execute a batch file.The batch file created through java itself. My query is At runtime created batch file executes well on my machine(XP) and on windows server 2008 R2. But on Windows Server 2003 Batch file gets crested but it doesnt execute. But if i double click the batch file it executes.

    Process process = runtime.exec("cmd /c start /b "+batchFile.getPath());
    

  • aviad

    It can be because of (lack of) administrator permissions required for running batches from cmd.exe on windows server 2003.

    Method 1 Grant the cmd.exe program Read and Execute permissions for the user account that the batch job runs under. To do this, follow these steps:

    1. Click Start, and then click Windows Explorer.
    2. Locate and then right-click the cmd.exe file. The Cmd.exe file is located in the %windir%\System32 folder.
    3. Click Properties.
    4. Click the Security tab.
    5. Click Add.
    6. In the Enter the object names to select box, type the user name that the batch job runs under, and then click OK two times.

    Note When you add the user, the user is automatically granted Read and Execute permissions. 7. Click Yes when you are prompted to continue.

    Method 2 Grant Read and Execute permissions for the cmd.exe file to the Batch group. This permits all batch processes to run the command processor. To do this, follow these steps:

    1. Click Start, and then click Windows Explorer.
    2. Locate and then right-click the cmd.exe file. The cmd.exe file is located in the %windir%\System32 folder.
    3. Click Properties.
    4. Click the Security tab.
    5. Click Add.
    6. In the Enter the object names to select box, type Batch, and then click OK two times.
    7. Click Yes when you are prompted to continue.

    For more information, please refer to the following Microsoft KB article:

    “Access is denied” error message when you run a batch job on a Windows Server 2003-based computer