Home All Groups Group Topic Archive Search About

Output from process.start

Author
18 Jan 2006 12:55 PM
Philip Wagenaar
How can I get the output from a process.start.

Example:

Process.Start("c:\windows\system32\rp", PrintQueue & " " & filename,
Username, pass, ComputerName)

How do I get the output of this into a string?

Author
18 Jan 2006 1:19 PM
Herfried K. Wagner [MVP]
"Philip Wagenaar" <philip.wagenaar@online.nospam> schrieb:
> How can I get the output from a process.start.
>
> Example:
>
> Process.Start("c:\windows\system32\rp", PrintQueue & " " & filename,
> Username, pass, ComputerName)

<URL:http://dotnet.mvps.org/dotnet/samples/misc/RedirectConsole.zip>

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>
Author
18 Jan 2006 2:14 PM
Phill W.
"Philip Wagenaar" <philip.wagenaar@online.nospam> wrote in message
news:CA7C3A36-A747-4B83-95F7-FEBD0F78F4B0@microsoft.com...
> How can I get the output from a process.start.
> Example:
> Process.Start("c:\windows\system32\rp", PrintQueue & " " & filename,
> Username, pass, ComputerName)
>
> How do I get the output of this into a string?

Look into launching your process using the ProcessStartInfo class :

Dim starter as New ProcessStartInfo( _
    "rp" _
    , PrintQueue & " " & filename _
    & " " Username _
    & " " & pass _
    & " " & ComputerName _
    )

With starter
    .WorkingDirectory = "c:\windows\system32"
    .RedirectStandardOutput
End With

Process.Start( starter )
Process.WaitForExit()

If Process.StandardOutput.ReadToEnd().IndexOf( "ERROR" ) > -1 Then
    ' Oops
End If

HTH,
    Phill  W.