Mail Archives: djgpp/2001/06/29/18:49:04
> Date: Fri, 29 Jun 2001 11:32:35 -0500
> From: Jonathon Merz <jmerz42 AT earthlink DOT net>
>
> Is this a bug or am I missing something?
You are missing something ;-)
> main()
> {
> char *comspec_value = getenv("COMSPEC");
> printf("%s\n", comspec_value);
> }
>
> When compiled with DJGPP's gcc on WinNT 4, the output is:
>
> C:\WINNT\SYSTEM32\COMMAND.COM
>
> The trouble is that on NT 4, (and I have verified this in my shell) COMSPEC is
> set to c:\winnt\system32\cmd.exe. The correct value is output when compiled
> under several other compilers.
This is a ``feature'' of Windows NT: when a DOS program runs, it gets
COMMAND.COM as the value of COMSPEC in its environment, even if
outside the program COMSPEC has a different value. Windows NT doesn't
want DOS programs to think they are on Windows, it pretends to be DOS.
Likewise, all the names of important (or maybe all, I forget)
environment variables are up-cased when they are passed to DOS
programs. Thus, Path is converted to PATH, ComSpec is converted to
COMSPEC, etc.
There's nothing (AFAIK) a DOS program can do to avoid this, because
this behavior is entirely inside the NT DOS emulator.
However, why is this a problem in your case? DOS programs in general
and DJGPP programs in particular should not normally care about this.
> if there is a way to identify the operating system the program is
> running under
It's not easy. For example, there's no easy way we know of to
distinguish NT from Windows 2000. But if you don't care about the
difference, call _get_dos_version(1), and if it returns the version
5.50, you are on NT.
- Raw text -