@@ -578,14 +578,27 @@ private static bool ExecuteExecutable(string executablePath, string arguments, b
578
578
try
579
579
{
580
580
var timer = new Timer ( ) ;
581
- var process = new Process { StartInfo = { CreateNoWindow = ! showWindow , FileName = executablePath , Arguments = arguments } } ;
582
- process . Start ( ) ;
583
- if ( ! process . WaitForExit ( Convert . ToInt32 ( TimeSpan . FromDays ( 1 ) . TotalMilliseconds ) ) )
581
+ var process = new Process
584
582
{
585
- Log . Error ( "Scheduler executable task didn't end on its own: " + executablePath ) ;
586
- process . Kill ( ) ;
587
- }
583
+ StartInfo =
584
+ {
585
+ FileName = executablePath ,
586
+ Arguments = arguments ,
587
+ CreateNoWindow = ! showWindow ,
588
+ RedirectStandardError = true ,
589
+ RedirectStandardOutput = true ,
590
+ UseShellExecute = false
591
+ }
592
+ } ;
593
+ process . OutputDataReceived += ExecutableOutputDataReceivedHandler ;
594
+ process . ErrorDataReceived += ExecutableErrorDataReceivedHandler ;
595
+ process . Start ( ) ;
596
+ process . BeginOutputReadLine ( ) ;
597
+ process . BeginErrorReadLine ( ) ;
598
+ process . WaitForExit ( ) ;
599
+
588
600
timer . Stop ( ) ;
601
+
589
602
return ( Utilities . SynchronisationTaskExitCode ) process . ExitCode == Utilities . SynchronisationTaskExitCode . Success ;
590
603
}
591
604
catch ( Exception ex )
@@ -773,6 +786,17 @@ private static void VbsOutputDataReceivedHandler(object sender, DataReceivedEven
773
786
{
774
787
Log . Debug ( $ "{ LoggingPrefix } VBS: { e . Data } ") ;
775
788
}
789
+
790
+ private static void ExecutableErrorDataReceivedHandler ( object sender , DataReceivedEventArgs e )
791
+ {
792
+ if ( e != null && ! string . IsNullOrEmpty ( e . Data ) )
793
+ Log . Error ( $ "{ LoggingPrefix } Executable: { e . Data } ") ;
794
+ }
795
+
796
+ private static void ExecutableOutputDataReceivedHandler ( object sender , DataReceivedEventArgs e )
797
+ {
798
+ Log . Debug ( $ "{ LoggingPrefix } Executable: { e . Data } ") ;
799
+ }
776
800
#endregion
777
801
}
778
802
}
0 commit comments