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. Accessing the command line via Visual C++

Accessing the command line via Visual C++

Scheduled Pinned Locked Moved C / C++ / MFC
c++helpquestion
3 Posts 3 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.
  • N Offline
    N Offline
    N Rackley
    wrote on last edited by
    #1

    Hey everyone! I'm currently working on a project that is going to require access to various command line applications. Mostly in order to grab status updates from various processes that are running on the system. A sample of the command line program would be as follows:

    C:\Program\Folder>System.exe -Enable "10:22:00" -Disable "10:23:00"
    SYSTEM ONLINE - 11/25/2009 10:22:35 GMT
    SYSTEM ONLINE - 11/25/2009 10:22:40 GMT
    SYSTEM ONLINE - 11/25/2009 10:22:45 GMT
    SYSTEM ONLINE - 11/25/2009 10:22:50 GMT
    SYSTEM ONLINE - 11/25/2009 10:22:55 GMT
    SYSTEM OFFLINE - 11/25/2009 10:23:00 GMT
    SYSTEM OFFLINE - 11/25/2009 10:23:05 GMT
    SYSTEM OFFLINE - 11/25/2009 10:23:10 GMT

    Etc. Etc. Etc. I need to be able to grab that system status from this and other programs and return them to a GUI application in Visual C++. How can I grab the resultant output of the console as a string? I realize that many people simply dump the data to a file and then read from the file, but I'm looking for something a bit more direct. Is this even the correct way to approach the problem of grabbing status from an external process? My restrictions are that it does have to be for Windows and in Visual C++. Thanks for the help! -N. Rackley

    L M 2 Replies Last reply
    0
    • N N Rackley

      Hey everyone! I'm currently working on a project that is going to require access to various command line applications. Mostly in order to grab status updates from various processes that are running on the system. A sample of the command line program would be as follows:

      C:\Program\Folder>System.exe -Enable "10:22:00" -Disable "10:23:00"
      SYSTEM ONLINE - 11/25/2009 10:22:35 GMT
      SYSTEM ONLINE - 11/25/2009 10:22:40 GMT
      SYSTEM ONLINE - 11/25/2009 10:22:45 GMT
      SYSTEM ONLINE - 11/25/2009 10:22:50 GMT
      SYSTEM ONLINE - 11/25/2009 10:22:55 GMT
      SYSTEM OFFLINE - 11/25/2009 10:23:00 GMT
      SYSTEM OFFLINE - 11/25/2009 10:23:05 GMT
      SYSTEM OFFLINE - 11/25/2009 10:23:10 GMT

      Etc. Etc. Etc. I need to be able to grab that system status from this and other programs and return them to a GUI application in Visual C++. How can I grab the resultant output of the console as a string? I realize that many people simply dump the data to a file and then read from the file, but I'm looking for something a bit more direct. Is this even the correct way to approach the problem of grabbing status from an external process? My restrictions are that it does have to be for Windows and in Visual C++. Thanks for the help! -N. Rackley

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

      You will probably need to use the system() or _popen() call to get what you need. Take a look at the MSDN references[^] for more information.

      1 Reply Last reply
      0
      • N N Rackley

        Hey everyone! I'm currently working on a project that is going to require access to various command line applications. Mostly in order to grab status updates from various processes that are running on the system. A sample of the command line program would be as follows:

        C:\Program\Folder>System.exe -Enable "10:22:00" -Disable "10:23:00"
        SYSTEM ONLINE - 11/25/2009 10:22:35 GMT
        SYSTEM ONLINE - 11/25/2009 10:22:40 GMT
        SYSTEM ONLINE - 11/25/2009 10:22:45 GMT
        SYSTEM ONLINE - 11/25/2009 10:22:50 GMT
        SYSTEM ONLINE - 11/25/2009 10:22:55 GMT
        SYSTEM OFFLINE - 11/25/2009 10:23:00 GMT
        SYSTEM OFFLINE - 11/25/2009 10:23:05 GMT
        SYSTEM OFFLINE - 11/25/2009 10:23:10 GMT

        Etc. Etc. Etc. I need to be able to grab that system status from this and other programs and return them to a GUI application in Visual C++. How can I grab the resultant output of the console as a string? I realize that many people simply dump the data to a file and then read from the file, but I'm looking for something a bit more direct. Is this even the correct way to approach the problem of grabbing status from an external process? My restrictions are that it does have to be for Windows and in Visual C++. Thanks for the help! -N. Rackley

        M Offline
        M Offline
        Michael Schubert
        wrote on last edited by
        #3

        Have a look at this page: http://support.microsoft.com/kb/190351[^] Possibly not exactly what you are looking for but it gets you started on Input/Output handles and redirection. Also, search for "redirection" in the following article section: http://www.codeproject.com/KB/threads/[^]

        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