In recent versions of PE files there is a stub to show for MS DOS users the sentence This program can not be run in DOS mode
. Why such message still exists althogh it wastes about 38 bytes? Is there any one still uses MS-DOS?

- 12,247
- 36
- 89
- 150
-
They probably mean -- don't run from the command line – zellio Oct 21 '11 at 17:04
4 Answers
It's still there because there's no easy way to remove it without breaking the file format, and nobody seems to think 38 bytes per executable is worth the trouble. The requirements on section alignment nearly always "waste" a lot more than that anyway.

- 476,176
- 80
- 629
- 1,111
Somewhere, someone is still using DOS. And, for backwards compatibility issues, the 38 bytes still need to be there. Even if no one is using DOS.
You would be amazed to know how many hoops the Windows code jumps through to remain backwards compatible.

- 161,458
- 45
- 265
- 341
When the PE format was introduced (year 1994, Windows NT 3.1), DOS was still very much around. The risk that a Windows EXE would be run from DOS by mistake was very real. So they needed to make Windows EXE's superficially compatible with the DOS loader. So that in such a scenario the program would do something (i. e. print a message and quit) instead of crashing randomly.
Obviously, somehow modifying the DOS loader to recognize the Windows EXE's was not an option. And there was no "platform/architecture" identifier in the DOS exe header, like in PE - there was no built-in mechanism for future introduction of incompatibility. Also, "This is a Windows program, please run under Windows" is a much friendlier message that "This program is not compatible with your system".
The DOS stub was also a part of the older 16-bit Windows EXE format ("NE" for "New Executable"). The path to the stub was even a settable linker parameter, so that making a "fat binary" of a sorts was possible - the Windows bits would be your program for Windows, and the DOS stub would be the same program (i. e. same functionality) for DOS. AFAIK, very few people ever took advantage of that.

- 59,826
- 25
- 160
- 281
-
-
-
The installer for QEMM97 was also such a fat binary. Run it from DOS and you get a text-mode installer that installs only the DOS bits. Run it from Windows and you get a graphical installer that installs everything. – ssokolow Nov 30 '17 at 12:50
While Disk Operating System (DOS) is not in use these days, DOS-mode which is basically command line (or console mode) still exists and very popular. By DOS-MODE it probably means commandline mode. Console Application are very popular and used everywhere esp in test and development environment.

- 16,560
- 16
- 115
- 136
-
5Command-line/console applications are sometimes improperly referred to as DOS applications, but the DOS stub in the PE format really is for MS-DOS. It has nothing to do with console apps. – Harry Johnston Oct 25 '11 at 02:13