Invoking a DOS command within a C++ program

  • Thread starter mathewsdw@sbcglobal.net
  • Start date
M

mathewsdw@sbcglobal.net

Guest
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????
 
May 20, 2008
11,400
99
Syracuse, NY, USA
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
 
Similar threads
Thread starter Title Forum Replies Date
Phileosophos LIST edit not invoking my specified editor Support 4
Steve Pitts Documentation Script errors invoking help Support 15
S Installing on Win 7 without invoking UAC Support 2
S WAD Invoking BDEBUGGER changes window title to "TCC Prompt" Support 7
David McClelland Invoking TCC FROM Perl 5.12 Support 3
Z [dos] into - for loop - the bp is not hit Support 5
H DOS CMD Sort+Add Sequence+Remove Sequence number Support 12
T Regex engine doesn't recognize native DOS line endings Support 2
A CDD and DOS filenames Support 1
vefatica _DO_LOOP and nested DOs? Support 8
Joe Caverly How to? Run DOS .exe's the same way Wine does... Support 3
T Associating BTM files with IDE results in DOS box Support 33
vefatica Single-line DO inside nested multi-line DOs? Support 9
D tcmd 12 and DOS Support 4
R DOS programs Support 4
M Ansi.sys and old Dos programs Support 7
B TCC 11 & Windows 7 64bit & DOS apps? Support 6
epement Coerce DOS programs to handle LFN Support 0
Dmitry L. Kobyakov How to? How to remove the record of the old version of the Take Command? Support 5
D Can alias pass parameters to for command? Support 3
samintz How to? Search for %(command) in Help? Support 1
T VIEW only works from command line Support 14
rconn News Take Command / TCC / CMDebug / TCC-RT v28 Released Support 0
T Take Command 28: Lua reports version 5.4.0 (5.4.3 expected) Support 0
Jay Sage WAD Possible Bug With OPTION Command With @FILE Support 5
rconn News Take Command / TCC / CMDebug / TCC-RT 27.01.24 uploaded Support 0
J Take command does not start on Windows 10 Support 3
vefatica `Back quotes` - command line vs. batch file Support 5
Jay Sage WAD Failure of Alias Command with /Z Option Support 14
Phileosophos Is there any way to open the Take Command options dialog from the command line? Support 8
Phileosophos Command-line Editing Shortkeys That Fail Support 6
fpefpe How to? free (internal) command Support 0
rconn News Take Command / TCC / CMDebug / TCC-RT 27.01.23 uploaded Support 0
T How to? retain command history across reboot? Support 6
rconn News Take Command / TCC / CMDebug / TCC-RT v27.01 Build 22 Uploaded Support 0
Jay Sage Bug With Flow Control and/or Command Grouping Support 2
GermanDirk How to? EVENTLOG Command with simple User Rights not functional Support 4
Jay Sage Take Command Is Too Fast! Support 4
Jay Sage Comparison of IF with Command Group and IFF Support 6
D Open Windows 10 Photos app from command line Support 11
rconn News Take Command / TCC / CMDebug / TCC-RT 27.0.21 uploaded Support 0
rconn News Take Command / TCC / CMDebug / TCC-RT 27.0.20 uploaded Support 0
U Can not get/start Take Command gui Support 1
rconn News Take Command / TCC / CMDebug / TCC-RT 27.0.19 Support 0
S Increasing Font Point Size in Command Tabs Support 2
mfarah Fixed The DATE command produces the wrong error message. Support 1
vefatica Command name mix-up Support 3
FreezerBurnt "Missing SETLOCAL" when initializing Visual Studio Command Prompt. Support 9
E How to? Closing desktop created by DESKTOP command Support 10
rconn News Take Command / TCC / CMDebug / TCC-RT v27.0.18 Support 0

Similar threads