Click to See Complete Forum and Search --> : Executing MS DOS commands from Windows app
LimsDan
June 20th, 2002, 08:57 PM
Hi,
I seem to have completely forgotten how to execute a MS DOS command from a Windows app! Can you help?
I just want to execute the copy command!
Thanks,
Daniel
Zeeshan
June 20th, 2002, 11:56 PM
Use system function like
system("dir");
Hope it helps.
LimsDan
June 21st, 2002, 12:10 PM
Thanks for your help. It was very obvious. I just had a mental block.
But is there a way to copy a file with out having the Console screen come up?
Daniel
JMS
June 21st, 2002, 01:34 PM
ShellExecute( "c:\\MyProgram.exe", SW_HIDE);
Bob Davis
June 21st, 2002, 07:18 PM
For some powerful Win32 API file operation routines, try looking up SHFileOperation() in MSDN.
Axter
June 21st, 2002, 10:26 PM
You can use the CopyFile() API function
There are several methods for launching another program from one program.
You can use _spawn(), _exec(), system(), WinExec(), ShellExecute(), ShellExecuteEx(), and CreateProcess().
The system() function is a more portable function.
WinExec(), ShellExecute(), ShellExecuteEx(), and CreateProcess() are unique to Windows programming. All four windows functions allow for launching an application in the background (window-hidden).
The WinExec() is the easiest of the four to use. It only takes two arguments, however MS recommends using the CreateProcess() instead of WinExec on all 32-bit programs.
See the following link for more details:
http://www.axter.com/faq/topic.asp?TOPIC_ID=24&FORUM_ID=4&CAT_ID=9&Topic_Title=How+to+launch+a+program+from+another+program+in+VC&Forum_Title=C%2FC%2B%2B
LimsDan
July 15th, 2002, 05:40 PM
Thanks Bob,
The SHFileOperation() did the trick very nicely
Daniel
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.