Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. use c++ to drive cmd window and get responses

use c++ to drive cmd window and get responses

Scheduled Pinned Locked Moved C / C++ / MFC
questioncsharpc++visual-studio
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    bkelly13
    wrote on last edited by
    #1

    Windows 7, Visual Studio 2008, C++ Question: Is there a way to use C++ with a dialog or other GUI to open a DOS CMD window, feed it commands, let it run, and capture the output from those commands? Parts of the output will be used for follow up commands. We may need to change directory more than once so consistency between commands will be rather helpful. Motivation: A very extensive and heavily used application is all command line. We want to create a GUI to drive it.

    Thanks for your time If you work with telemetry, please check this bulletin board: http://www.bkelly.ws/irig\_106/

    L D 2 Replies Last reply
    0
    • B bkelly13

      Windows 7, Visual Studio 2008, C++ Question: Is there a way to use C++ with a dialog or other GUI to open a DOS CMD window, feed it commands, let it run, and capture the output from those commands? Parts of the output will be used for follow up commands. We may need to change directory more than once so consistency between commands will be rather helpful. Motivation: A very extensive and heavily used application is all command line. We want to create a GUI to drive it.

      Thanks for your time If you work with telemetry, please check this bulletin board: http://www.bkelly.ws/irig\_106/

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      bkelly13 wrote:

      open a DOS CMD window

      DOS is long dead; it's just a command window these days. You can do this via the CreateProcess[^] function in Windows.

      1 Reply Last reply
      0
      • B bkelly13

        Windows 7, Visual Studio 2008, C++ Question: Is there a way to use C++ with a dialog or other GUI to open a DOS CMD window, feed it commands, let it run, and capture the output from those commands? Parts of the output will be used for follow up commands. We may need to change directory more than once so consistency between commands will be rather helpful. Motivation: A very extensive and heavily used application is all command line. We want to create a GUI to drive it.

        Thanks for your time If you work with telemetry, please check this bulletin board: http://www.bkelly.ws/irig\_106/

        D Offline
        D Offline
        David Crow
        wrote on last edited by
        #3

        See here and here.

        "One man's wage rise is another man's price increase." - Harold Wilson

        "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

        "You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles

        B 1 Reply Last reply
        0
        • D David Crow

          See here and here.

          "One man's wage rise is another man's price increase." - Harold Wilson

          "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

          "You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles

          B Offline
          B Offline
          bkelly13
          wrote on last edited by
          #4

          thanks for the links. No, DOS is not dead. There are still some things to do with command line. Power Shell is a supercharged DOS. It can do much that the various Unix/Linux scripts do. I did some more searching and remembering. Now I have concluded that using Expect to drive this command line application is probably the text way. ExpectTk is probably even better. It will be better and easier to develop than a C++ solution. Thanks for taking the time to read and respond.

          Thanks for your time If you work with telemetry, please check this bulletin board: http://www.bkelly.ws/irig\_106/

          H 1 Reply Last reply
          0
          • B bkelly13

            thanks for the links. No, DOS is not dead. There are still some things to do with command line. Power Shell is a supercharged DOS. It can do much that the various Unix/Linux scripts do. I did some more searching and remembering. Now I have concluded that using Expect to drive this command line application is probably the text way. ExpectTk is probably even better. It will be better and easier to develop than a C++ solution. Thanks for taking the time to read and respond.

            Thanks for your time If you work with telemetry, please check this bulletin board: http://www.bkelly.ws/irig\_106/

            H Offline
            H Offline
            Heng Xiangzhong
            wrote on last edited by
            #5

            To be exact, DOS is a operation system, and command line in windows is just a application, we call it console. You can use GetStdHandle to get the standard output in a running GUI application, or use CreateProcess to spawn a process and redirect it's output to do the same thing.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups