Board index » cppbuilder » Execute a dos command

Execute a dos command

Can anybody tell me how to execute a dos command?

Thank you


Re:Execute a dos command


Well that isn't really an IDE related question and proably shouldn't
have been posted here but I'll answer it anyway. Lookup
'ShellExecute' in the online help.

Andrue Cope
[Bicester, UK]

Re:Execute a dos command

Look at the function named system

.  Ed

Re:Execute a dos command

pivo wrote:

> Can anybody tell me how to execute a dos command?

system will do it, but it will print the results to the console. If you are in a GUI
app, I think it may even popup a console window to run in. If you need to capture the
output of a dos command, then you should use CreateProcess to launch cmd.exe or cmd.exe has a /c switch that allows you to pass in the command. for

cmd.exe /c dir

is equivalent to running dir at the command prompt.

To capture the output of dir, you would need to create some unnamed pipes and pass
those pipes to CreateProcess. How to capture the output of a program is a separate
topic. Post a question to the winapi group if you need help on that.

Harold Howe [TeamB]

Other Threads