CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Jun 2002
    Posts
    11

    Unhappy Executing MS DOS commands from Windows app

    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

  2. #2
    Join Date
    Apr 2000
    Location
    Frederick, Maryland
    Posts
    507
    Use system function like

    Code:
    system("dir");
    Hope it helps.

  3. #3
    Join Date
    Jun 2002
    Posts
    11
    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

  4. #4
    Join Date
    May 2000
    Location
    Washington DC, USA
    Posts
    715
    ShellExecute( "c:\\MyProgram.exe", SW_HIDE);

  5. #5
    Join Date
    Jan 2001
    Posts
    588
    For some powerful Win32 API file operation routines, try looking up SHFileOperation() in MSDN.

  6. #6
    Join Date
    Aug 2000
    Location
    New Jersey
    Posts
    968
    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?T...le=C%2FC%2B%2B

  7. #7
    Join Date
    Jun 2002
    Posts
    11
    Thanks Bob,

    The SHFileOperation() did the trick very nicely

    Daniel

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured