WAD Possible Incorrect COMSPEC handling

Aug 30, 2013
I’m trying to fix a vendor’s program that has CMD.EXE hard-coded as the command processor by writing a simple C shell program that merely passes command line parameters to whatever command processor is specified in the Windows COMSPEC environment variable. As a test, I wrote a simple program that uses getenv() to get COMSPEC and printf() to display it. Running it at a CMD.EXE prompt I get C:\Windows\system32\cmd.exe as expected. Running it at a TCC.EXE prompt I get the name of my own program rather than the path of the TCC executable. This happens under both the full version Take Command 14 and TCC/LE 13.

At the TCC command prompt, executing a SET command displays the correct value for COMSPEC.

  #include <stdio.h>
  #include <stdlib.h>

  int main(void)
      char *comspec;
      comspec = getenv("COMSPEC");
      printf("COMSPEC = %s\n",comspec);
      return 0;

I have compiled the program in both Watcom Open C/C++ and Borland C/C++ and get the same results with both of them so I can’t see this being a compiler bug. I could see it being a Windows bug or some setting that I need to change. I suppose it could even be a programming error on my part although the program is ridiculously simple (that’s often when I make mistakes <sigh>).

Anyone know why this might be happening?
May 20, 2008
Syracuse, NY, USA
Your problem is bizarre. "int main(void)" is somewhat unusual. Perhaps it confuses Borland/Watcom. How about

int main(int argc, char *argc[]) or int main(int argc, char *argc[], char *envp[])
Similar threads
Thread starter Title Forum Replies Date
Jay Sage WAD Possible Bug With OPTION Command With @FILE Support 5
M Is bash-like filename completion possible? Support 3
vefatica DO /P ... is this possible ... ? Support 5
I Possible Bug: History /n Returns Nothing Support 3
Jay Sage WAD Possible Bug in Batch Parameters Support 7
M @FileSize - How is this possible? Support 10
S Is restartable TCMD download possible? Support 6
H Possible V16 documentation error? Support 2
S How to? Is it possible for the IDE to start without plugins? Support 3
A How to? Is it possible to freeze one side of the console? Support 19
Vasilich How to? debugging files that use CALL command - possible?? Support 3
wbiebel Can this be possible: TCEXIT is not executed? Support 21
Frank VIEWing multiple files possible? Support 4
daniel347x Is it possible to send a line from the "command input" window to the tab without pressing "Enter", w Support 4
C Possible caching problem with http files Support 7
S Dir - case selection possible?? Support 3
T Possible to delete the new standard tab? Support 1
noahcoad Possible Bug? Launching 4nt.exe Goes Hairwire Support 10
G possible bug in SETDOS Support 4
M Something that does not seem possible... Support 2
D Is this possible, and how Support 0
Charles Dye REGDIR /T : incorrect localization of time stamps Support 4
S incorrect message at start Cancel batch job 4START.bat ? (Y/N/A) : Support 1
rps Fixed @filesize[...,a] space allocated values incorrect Support 2
M TCC incorrect dir output since Windows 1803 Support 6
Fross @Words Incorrect? Support 19
Steve Pitts WAD @MD5 returns incorrect results for strings Support 2
Phil Kane WAD v 17 Displays Incorrect OS Support 6
rps Documentation "Select" command switch order incorrect Support 4
R Fixed Bytes Allocated Total Incorrect in V17 b52 Support 1
M Incorrect ARGV1 when using linux-style paths Support 4
D Minor problem. Incorrect value internal var _dir_files Support 7
S WAD Incorrect _do_loop values Support 18
Dan Glynhampton Documentation v15 help: Incorrect Links Support 0
JohnQSmith WAD Incorrect results from @FILESIZE Support 9
T @ping: response code, data size and documentation incorrect Support 2
N Incorrect display under TCMD 13 Support 1
dcantor @AGEDATE example incorrect in help Support 0
T Incorrect file associations Support 8
C TC10 LIST - print with line nbrs incorrect Support 0
D D:\Settings\Application contains an incorrect path? Support 0
C COMSPEC constantly reset to TCC.EXE Support 6
vefatica "COMSPEC path" Support 2
R Fixed v17.0.54 Tab->COMSPEC Dialog Box Issue Support 2
vefatica TCMD's COMSPEC? Support 4
T Documentation Comspec not working Support 3
R How to set comspec to point to cmd.exe? Support 5
A Problem with comspec in TC 10.00.76 Support 8
C Comspec Oddies with cmd and quicken 2008 Support 5
Timothy Byrd COMSPEC incompatibility - v9 is different than v7 Support 8

Similar threads