delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2001/06/29/13:45:25

Message-ID: <3B3CADA3.4000506@earthlink.net>
Date: Fri, 29 Jun 2001 11:32:35 -0500
From: Jonathon Merz <jmerz42 AT earthlink DOT net>
User-Agent: Mozilla/5.0 (Windows; U; WinNT4.0; en-US; rv:0.9.1) Gecko/20010607
X-Accept-Language: en,pdf
MIME-Version: 1.0
To: djgpp AT delorie DOT com
Subject: Incorrect resolution of COMSPEC environment variable on WinNT
Reply-To: djgpp AT delorie DOT com

Is this a bug or am I missing something?

With the following code:


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.

If anyone sees a mistake, or if it is a bug, knows of a workaround for this, 
I'd love to hear it.  Alternatively, (This may be a newbie question, but I 
can't find any info in the docs on this) if there is a way to identify the 
operating system the program is running under, then I suppose I could hardcode 
in cmd.exe on WinNT.

Thanks in advance,

-Jon


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019