JDK-5005176 : (process) Can't run 16-bit DOS programs (.com files)
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.lang
  • Affected Version: 5.0
  • Priority: P4
  • Status: Closed
  • Resolution: Won't Fix
  • OS: windows_2000
  • CPU: generic
  • Submitted: 2004-02-28
  • Updated: 2007-08-02
  • Resolved: 2007-08-02
Related Reports
Relates :  
Relates :  
Description
If you try to run a 16-bit DOS program, e.g.

new ProcessBuilder(new String[]{"command.com","/C", "dir"}).start();

it fails by putting up a dialog box (even if the process is running "remotely")

16-bit MS-DOS subsystem
C:/WINNT/System32/ntvdm.exe
Error while setting up environment for the application.

while the analogous

new ProcessBuilder(new String[]{"cmd.exe","/C", "dir"}).start();

works perfectly.
###@###.### 2004-03-02

Comments
EVALUATION It's unlikely we will ever make the enormous implementation and (especially!) testing effort required to support the dying .com executable format, so I am closing this Will Not Fix.
02-08-2007

EVALUATION Starting DOS programs correctly, without popping up an annoying console window is, in general, extremely tricky. One has to take into account whether the invoking application has a console, whether the invoked program is a DOS program, whether this is Win98 or WinNT, etc... Particularly tricky is running a DOS program without popping up a transient console window. This can be done by starting up an intermediate non-DOS program with a hidden console, and running the DOS program within that. The proper technique can be found in the Tcl/Tk distribution at TclWinPipe.c A less complete, but much easier, solution would be to: - replace CREATE_NO_WINDOW with DETACHED_PROCESS in the CreateProcess call. - if CreateProcess fails with error code 5 (Invalid call), then try again without DETACHED_PROCESS, possibly causing an annoying popup console window that most Windows users already live with. ###@###.### 2004-02-27 Instead of the above, a much simpler (but still incomplete) fix is to apply the algorithm to determine whether to use DETACHED_PROCESS in the CreateProcess call, but to use it on both Win98 and WINNT. Currently, it is only used on Win98. There will be an annoying popup window if java is running without a console, and it starts up a 16-bit DOS application. That can also be fixed, but is much harder and riskier. ###@###.### 2004-03-02 Here are some more aspects to this problem: - Most of the ".com" files in NT's system directory (like tree.com) are really 32-bit PE executables and don't need a console. command.com is the most significant 16-bit program left. - If we try to detect 16-bit programs, there is a price for false positives (annoying console popup window). We need to take the binary structure of the executable (is it a PE executable?) and its extension into account. - There are no 16-bit programs at all on Win64, so this problem is non-existent there. This will help bring about the deserved demise of 16-bit programs that much faster. - The cmd /c ... workaround is effective and simple for the user to apply. Therefore, we will not fix this in Tiger. Hopefully it will be fixed in a followon release, as part of a rewrite of the process mechanism on Windows. ###@###.### 2004-03-29
29-03-2004

WORK AROUND If you really need to run something like command.com, add another level of indirection (all problems in computer science can be solved by...) by prepending "cmd.exe", "/C" to the command line ... new ProcessBuilder(new String[]{"cmd.exe", "/C", "command.com", "/C", "dir"}) .start(); ###@###.### 2004-02-27
27-02-2004