Accessing the command line via Visual C++
-
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 GMTEtc. 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
-
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 GMTEtc. 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
-
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 GMTEtc. 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
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/[^]