I want to run lmutil.exe with the arguments -a, -c, and 3400@takd, then put everything that command line prompt generates into a text file. What I have below isn't working.
If I step through the process, I get errors like "threw an exception of type System.InvalidOperationException"
Process p = new Process();
p.StartInfo.FileName = @"C:\FlexLM\lmutil.exe";
p.StartInfo.Arguments = "lmstat -a -c 3400@tkad>Report.txt";
p.Start();
p.WaitForExit();
All I want is for the command line output to be written to Report.txt
To get the Process
output you can use the StandardOutput
property documented here.
Then you can write it to a file:
Process p = new Process();
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.UseShellExecute = false;
p.StartInfo.FileName = @"C:\FlexLM\lmutil.exe";
p.StartInfo.Arguments = "lmstat -a -c 3400@tkad";
p.Start();
System.IO.File.WriteAllText("Report.txt", p.StandardOutput.ReadToEnd());
p.WaitForExit();
p.Close();