c# - How to Run a Program from a Console Application? -
i looking resources have examples creating console application. past "hello world" stage stumped @ point need run application. have string need run pulled batch file trying automate in c# app. need knowing classes , namespaces have functionality need run it.
edit: sorry poorly asked question. i'll rewrite it.
i trying create console application replace batch file have partially written. of data , file manipulations need more complex can done in batch file. far reading, writing, , manipulating files fine. having difficulty when trying figure out how run command execute application on server proper arguments being passed in.
update: coworker gave me following code snippit needed move forward. sorry question worded badly.
public static string mydosmethod() { processstartinfo si = new processstartinfo("cmd.exe"); si.redirectstandardinput = true; si.redirectstandardoutput = true; si.useshellexecute = false; process p = process.start(si); p.standardinput.writeline(@"cd \windows\system32"); p.standardinput.writeline("exit"); try { return p.standardoutput.readtoend(); } catch (exception e) { return e.message; } }
the question not clear, understood "i need start application console application; class can use?"
my answer is: should have @ static method process.start
(and in general @ class process
of namespace system.diagnostics
).
Comments
Post a Comment