Created
December 15, 2016 06:24
-
-
Save tdmitch/8e9444676dcfa79e5ba79f4bb8f60218 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try | |
{ | |
// Create new ProcessStartInfo with vars from above | |
ProcessStartInfo ps = new ProcessStartInfo(); | |
ps.FileName = exeName; | |
ps.Arguments = args; | |
ps.UseShellExecute = false; | |
ps.RedirectStandardError = true; | |
ps.RedirectStandardOutput = true; | |
ps.CreateNoWindow = true; | |
Process p = Process.Start(ps); | |
// Capture StdOut and StdErr into variables | |
Dts.Variables["vStdOutput"].Value = p.StandardOutput.ReadToEnd(); | |
Dts.Variables["vStdError"].Value = p.StandardError.ReadToEnd(); | |
// Wait for exit | |
p.WaitForExit(); | |
// Capture the exit code (0 = success) | |
Dts.Variables["vExitCode"].Value = p.ExitCode; | |
// Write standard output to log | |
bool fireAgain = true; | |
Dts.Events.FireInformation(0, "7Zip completion", Dts.Variables["vStdOutput"].Value.ToString(), string.Empty, 0, ref fireAgain); | |
} | |
catch (Exception ex) | |
{ | |
exceptionTxt = ex.Message; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment