Windows executing bat/cmd
Alan Bateman
Alan.Bateman at oracle.com
Sun Oct 5 01:21:58 UTC 2014
On 04/10/2014 16:54, Bernd Eckenfels wrote:
> Hello,
>
> I noticed that MSDN CreateProcess(W) talks about using "cmd /c" for
> executing .bat and .cmd files:
>
> "To run a batch file, you must start the command interpreter;
> set lpApplicationName to cmd.exe and set lpCommandLine to the
> following arguments: /c plus the name of the batch file."
>
> However the JDK implementation seems to accept an executable path pointing
> to a *.bat or *.cmd file.
>
>
It's for compatibility reasons. There is a lot of code that calls
Runtime.exec to run .cmd and .bat scripts. Early versions of the JDK
didn't do much validation in this area and just passed the input to the
win32 call. The checking has been tightened up a lot since and part had
to deal with compatibility and keeping existing applications working.
-Alan
More information about the core-libs-dev
mailing list