Here's a way. Error handling, etc. issues not shown.
ProcessStartInfo psi = new ProcessStartInfo();
psi.FileName = "NET";
psi.Arguments = "VIEW";
psi.UseShellExecute = false;
psi.RedirectStandardOutput = true;
psi.UseShellExecute = false; // cannot redirect if using shell execute
Process p = new Process();
p.StartInfo = psi;
p.Start();
string s = p.StandardOutput.ReadToEnd();
// do something with the captured output....
Console.WriteLine("Captured output from NET VIEW...\nHere it is:");
Console.WriteLine(s);
"Nancy" <an*******@discussions.microsoft.com> wrote in message
news:9f****************************@phx.gbl...
At run comand line, we could type DIR or NET VIEW ETC...
and the results are displayed on the screen.
How could I automatically save those results into a text
file?
I tried to do the following:
Dim StreamWriter As StreamWriter
StreamWriter = New StreamWriter(strFN)
StreamWriter.Write(Shell("NET VIEW",
AppWinStyle.NormalFocus, True))
AppWinStyle.NormalFocus, True, 1))
StreamWriter.Close()
NET VIEW is displayed but not saved into the file.
Open for suggestions!
Thanks, Nancy.