To start the EXE, I found from other postings that this will work:
System.Diagnostics.Process.Start("foo.exe","1 2 3 4")
How do I retrieve the output, which will be straight text, which I then want
to parse and eventually display on an ASP.NET page.
C# or VB code is fine. Thanks in advance.
Phil
Here's a snippet I collected from the DOTNET mailing list:
<codeSnippet language="C#">
Process commandPrompt = Process.Start("cmd.exe");
string dirResults;
commandPrompt.StandardInput.WriteLine("dir")
dirResults = commandPrompt.StandardOutput.ReadToEnd()
</codeSnippet>
--
Patrick Steele
An unhandled exception of type 'System.NullReferenceException' occurred in
ConsoleTest.exe
Additional information: Value null was found where an instance of an object
was required.
I tried other variations of your code below...but kept getting the same
error.
Phil
"Patrick Steele" <pst...@ipdsolution.com_> wrote in message
news:MPG.1601eb517...@msnews.microsoft.com...
try this:
// execute an application, return output string
string ExecuteCmdLineApp(string strCmd)
{
string output = "";
string error = "";
TempFileCollection tf = new TempFileCollection();
Executor.ExecWaitWithCapture(strCmd, tf, ref output, ref error);
StreamReader sr = File.OpenText(output);
StringBuilder strBuilder = new StringBuilder();
string strLine = null;
while (null != (strLine = sr.ReadLine()))
{
if ("" != strLine)
{
strBuilder.Append(strLine);
strBuilder.Append("\r\n");
}
}
sr.Close();
File.Delete(output);
File.Delete(error);
return strBuilder.ToString();
}
the source is from an german asp-page:
http://www.aspheute.com/artikel/20010220.htm
chris
"Phil Derksen" <pder...@yahoo.com> wrote in message
news:Ov3j1vyNBHA.576@tkmsftngp05...
Willy.
"Phil Derksen" <pder...@yahoo.com> wrote in message news:Ov3j1vyNBHA.576@tkmsftngp05...
"Phil Derksen" <pder...@yahoo.com> wrote in message
news:Ov3j1vyNBHA.576@tkmsftngp05...
--
"Phil Derksen" <pder...@yahoo.com> schrieb im Newsbeitrag
news:Ov3j1vyNBHA.576@tkmsftngp05...
>
> How do I retrieve the output, which will be straight text, which I
then want
> to parse and eventually display on an ASP.NET page.
>
> C# or VB code is fine. Thanks in advance.
Try it with DOS:
foo.exe 1 2 3 4 >output.txt
;-)
>
> Phil
>
>
p
"Phil Derksen" <pder...@mediaone.net> wrote in message
news:ukEj6O3NBHA.2036@tkmsftngp03...