CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Sep 2003
    Location
    Chennai, India
    Posts
    76

    Running Batch File from C++ Programme

    Hi,

    I would like to run a batch file from a c++ programme. Is there any command availabe that i can use for the above process.

    Thanks in Advance,
    Varadha

  2. #2
    Join Date
    Aug 2002
    Location
    Redmond, WA, USA
    Posts
    88
    Use CreateProcess to launch cmd.exe with the batch file you want to run.

    Ex. "cmd.exe /C mystuff.bat"

    The /C parameter of cmd.exe tells cmd.exe execute the supplied batch file and terminate when complete.

    Execute "cmd /?" at a command prompt to see what else you can do.

    Alternatively, you can call ShellExecute with the operation parameter set to NULL (so the default action is used). This should cause the batch file to be executed by the command processor (cmd.exe).

    - Robert

  3. #3
    Join Date
    Aug 2002
    Location
    germany
    Posts
    112

    Batch

    I' ve used the "system" command.

    system("BatchFile.bat");

    It works and never caused a problem.

  4. #4
    John E is offline Elite Member Power Poster
    Join Date
    Apr 2001
    Location
    Manchester, England
    Posts
    4,867
    This FAQ offers several methods. Just pick the one you prefer....
    "A problem well stated is a problem half solved.” - Charles F. Kettering

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