1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Invoking a DOS command within a C++ program

Discussion in 'Support' started by mathewsdw@sbcglobal.net, Apr 28, 2009.

  1. I have a C++ program that I'm writing that needs to execute a "standard" DOS (i. e., not TakeCommand specific) command that would probably require a significant amount of code to write myself assuming that I even knew offhand exactly how to write C++ code that performed the DOS command's function (I don't), and since the existing DOS command does exactly what I want to do, I don't need to write that code; I need to execute the existing DOS command from within my program. Bottom line before I go much further, I know how to do and have done the code to execute the command and it works (almost) exactly as I would like it to. (What the command is and what it does is not at all relevant to this question.) So you might be wondering that if I know how to execute the command and the command works exactly like I want it to (I'm using the C++ "system" function to invoke the command), what the issue is. The answer is simple: it's calling tcmd.exe or tcc.exe (I don't know which or exactly why rather than "cmd.exe", but I don't care) and tcmd/tcc is sending a line to sysout that says "CDD D:\". I don't want that output, particularly since it's mixed in with the other output of my program (which, of course, I do want!) . There's actually two questions here: where is the "CDD D:\" command coming from (I don’t remember and can not find a ".ini" file; the only thing that I can think of is that tcmd/tcc are in a directory on the D: drive and that's where it's coming from), and (this, as you might guess, is the important question) how do I get rid of that message????
     
  2. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,969
    Likes Received:
    30
    On Tue, 28 Apr 2009 22:01:09 -0500, "mathewsdw@sbcglobal.net"
    <> wrote:

    |I have a C++ program that I'm writing that needs to execute a "standard" DOS (i. e., *not* TakeCommand specific) command that would probably require a significant amount of code to write myself assuming that I even *knew* offhand exactly *how* to write C++ code that performed the DOS command's function (I don't), and since the *existing* DOS command does *exactly* what I want to do, I don't *need* to write that code; I need to execute the existing DOS command from within my program. Bottom line before I go much further, I know how to do and have done that and it works (almost) exactly as I would like it to. (What the command is and what it does is not at all relevant to this question.) So you might be wondering that if I know how to execute the command and the command works exactly like I want it to (I'm using the C++ "system" function to invoke the command), what the issue is. The answer is simple: it's calling tcmd.exe or tcc.exe (I don't know which or exactly why rat!
    | her than "cmd.exe", but I don't care) and tcmd/tcc is sending a line to sysout that says "CDD D:\".* I don't want that output, *particularly since it's mixed in the other output of my program (which, of course, I *do* want!) . There's actually two questions here: where is the "CDD D:\" command coming from (I * don’t remember* and can not find a ".ini" file; the only thing that I can think of is that tcmd/tcc are in a directory on the D: drive), and (this, as you might guess, is the *important* question) how do I *get rid* of that message????

    The system() function may honor the %COMSPEC% variable (I don't know) which may
    be set to TCC.EXE (and will be if you're **in** TCC when you start your app). Do
    you have a TCSTART.BAT/4STAR.BAT? The CDD could be coming from there.

    You might consider using CreateProcess() instead of system(). You can specify
    an exact command line ("CMD.EXE /c command", perhaps) as well as specify not to
    open a new console if already in one.
    --
    - Vince
     

Share This Page