c# - Capturing responses from shell -
when send command command prompt in run command prompt commands how can capture response future work in code or save it? possible capture responses when sending commands way in?
you need set redirectstandardoutput = true;
. example might be:
class program { static void main() { // // setup process processstartinfo class. // processstartinfo start = new processstartinfo(); start.filename = @"c:\7za.exe"; // specify exe name. start.useshellexecute = false; start.redirectstandardoutput = true; // // start process. // using (process process = process.start(start)) { // // read in text process streamreader. // using (streamreader reader = process.standardoutput) { string result = reader.readtoend(); console.write(result); } } } }
i grabbed example here, pasted code here posterity.
Comments
Post a Comment