views:

155

answers:

2

Hi All,

I am trying to run a console C++ application linking with my DLL files from the command prompt in a XP windows machine. Recently I have started getting "This program cannot be run in DOS mode." as an error message. As I understand this is a filler message in all DLL's to print if this exe was invoked in a pure MS-DOS environment. So Why am I getting this in a Windows CMD window? Is it telling me that one of my DLLs has a problem?

Also I observed immeditaly after the error message the Windows path depiction changes as follows

<--------------Screen Dump------------------------------>

C:\Program Files\MYPROGRAMS\APPLICATIONS>foo.exe This program cannot be run in DOS mode.

C:\PROGRA~1\MYPROG~1\APPLICAT~1>
<--------------Screen Dump------------------------------>

Why does the path text change to Win95 style(for want of better phrase)? Is it somehow setting the system into some compatibility mode?

Most of the googling indicates this error occuring only during installation(unlike my scenario). THis link http://www.personalcopy.com/doserror.htm talks about a variant but the checkboxes are no longer present in the DOS window properties.

Any help and pointers appreciated.

A: 

@Hans THis is the linker command (Answering because the text is too big for comments)

/OUT:"......\nt\win32\Release\foo.exe" /INCREMENTAL:NO /NOLOGO /MANIFEST /MANIFESTFILE:".\foo_cli\Release\foo.exe.intermediate.manifest" /DEBUG /PDB:".......\nt\win32\Release/foo.pdb" /SUBSYSTEM:CONSOLE /OPT:REF /OPT:ICF /LTCG /MACHINE:X86 /ERRORREPORT:PROMPT kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib "......\nt\win32\release\foo_other_tests.lib" "......\nt\win32\release\foo.lib" "......\nt\win32\release\foo_tests.lib" "......\nt\win32\release\foo_logger.lib" "......\nt\win32\release\ext1.lib" "......\nt\win32\release\ext2.lib"

OK...I tried running dumpbin on the exe and it is displaying "Error: At least one file was not a 32-bit or 64-bit Windows module." According to http://stackoverflow.com/questions/1320894/why-isnt-cl-exe-producing-a-valid-windows-module this might be a problem in one of the libraries? Looking further....
Ok..The issue is resolved due to some other problem while building. To answer the question the message "This program cannot be run in DOS mode." seems to be printed if windows command prompt could not recognize the exe and need not necessarily be due to any specific DOS or Windows signatures.
+1  A: 

First open the EXE with hex editor ,what u want to run .After open ,can u see the MZ signature at starting...if there is other than MZ ,there may be ,Exe is not a correct form....after this ,u can move next..

Rajakumar
I will accept this as an answer even though this did not help me but seems to be the right approach to take under these conditions.