Java Run batch file issue on windows server 2003 versus windows server 2008-Collection of common programming errors
bernieUsing 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());
aviadIt can be because of (lack of) administrator permissions required for running batches from
cmd.exeon windows server 2003.Method 1 Grant the
cmd.exeprogram Read and Execute permissions for the user account that the batch job runs under. To do this, follow these steps:- Click Start, and then click Windows Explorer.
- Locate and then right-click the
cmd.exefile. The Cmd.exe file is located in the%windir%\System32folder. - Click Properties.
- Click the Security tab.
- Click Add.
- 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.exefile to the Batch group. This permits all batch processes to run the command processor. To do this, follow these steps:- Click Start, and then click Windows Explorer.
- Locate and then right-click the
cmd.exefile. Thecmd.exefile is located in the%windir%\System32folder. - Click Properties.
- Click the Security tab.
- Click Add.
- In the Enter the object names to select box, type Batch, and then click OK two times.
- 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