using
System
;
using
System
.
Diagnostics
;
using
System
.
IO
;
class
Program
{
static
void
Main
()
{
//
// Setup the process with the ProcessStartInfo class.
//
ProcessStartInfo
start
=
new
ProcessStartInfo
();
start
.
FileName
=
@"D:\XXXXXg\XXXXX.exe"
;
// Specify exe name.
start
.
UseShellExecute
=
false
;
start
.
RedirectStandardOutput
=
true
;
//
// Start the process.
//
using
(
Process
process
=
Process
.
Start
(
start
))
{
process
.
OutputDataReceived
+=
new
DataReceivedEventHandler
(
process_OutputDataReceived
);
process
.
BeginOutputReadLine
();
process
.
WaitForExit
();
}
}
static
void
process_OutputDataReceived
(
object
sender
,
DataReceivedEventArgs
e
)
{
if
(
null
!=
e
)
{
Console
.
WriteLine
(
e
.
Data
);
}
}
}