C program to invoke commands and retrieve responses from windows command prompt
I'm trying to create a program that will run commands like ping, ipconfig, etc. in the windows command prompt as well as retrieve (and parse) the responses from those commands. Was wondering if someone could point me in the right direction on how to do this, or any useful site links on this
Thank you kindly,
Look into popen/pclose in stdio.h.
I suppose the first question to pop into my head is ... Why not just use the command prompt?
However; you should know there are windows API calls for almost all of that stuff and you don't need to shell out and do convoluted data gathering to use them...
If you are using ping to get a remote machine's IP address (a common abuse of the program) you can just call gethostbyname() from the Winsock API....
If you are looking to use ipconfig to harvest local IPs, you can simply call, yep, gethostbyname() using the result of GetComputerName() to retrive IPs for your local system.
Yes, what you want to do is possible but it is s...l...o...w and very error prone.