I want to execute a batch command and save the output to a string, but I can only execute the file and cannot save the contents to a string.
Batch file:
@ echo off
"C: \ lmxendutil.exe" -licstatxml -host serv005 -port 6200> Notepad C: \ Temp \ HW_Lic_XML.xml C: \ Temp \ HW_Lic_XML.xml
C # code:
private void btnShowLicstate_Click(object sender, EventArgs e) { string command = "'C:\\lmxendutil.exe' -licstatxml -host lwserv005 -port 6200"; txtOutput.Text = ExecuteCommand(command); } static string ExecuteCommand(string command) { int exitCode; ProcessStartInfo processInfo; Process process; processInfo = new ProcessStartInfo("cmd.exe", "/c " + command); processInfo.CreateNoWindow = true; processInfo.UseShellExecute = false;
I want to output to a string and do it directly in C # without a batch file, is this possible?
source share