I used this code for a similar task (its a C# DTF custom action):
// your process data
ProcessStartInfo processInfo = new ProcessStartInfo() {
CreateNoWindow = true,
LoadUserProfile = true,
UseShellExecute = false,
RedirectStandardOutput = true,
StandardOutputEncoding = Encoding.UTF8,
...
};
Process process = new Process();
process.StartInfo = processInfo;
process.OutputDataReceived += (object sender, DataReceivedEventArgs e) =>
{
if (!string.IsNullOrEmpty(e.Data) && session != null)
{
// HERE GOES THE TRICK!
Record record = new Record(1);
record.SetString(1, e.Data);
session.Message(InstallMessage.ActionData, record);
}
};
process.Start();
process.BeginOutputReadLine();
process.WaitForExit();
if (process.ExitCode != 0) {
throw new Exception("Execution failed (" + processInfo.FileName + " " + processInfo.Arguments + "). Code: " + process.ExitCode);
}
process.Close();