Example #1
0
        public LocalProcess Start(IWorkContext context)
        {
            Verify.IsNotNull(nameof(context), context);
            Verify.IsNotEmpty(nameof(File), File);

            Process = new Process();
            Process.StartInfo.FileName         = File;
            Process.StartInfo.Arguments        = Arguments.IsNotEmpty() ? Arguments : null;
            Process.StartInfo.WorkingDirectory = WorkingDirectory.IsNotEmpty() ? WorkingDirectory : null;

            Process.StartInfo.UseShellExecute = UseShellExecute;
            Process.StartInfo.CreateNoWindow  = CreateNoWindow;

            if (!UseShellExecute)
            {
                Process.StartInfo.RedirectStandardOutput = true;
                Process.StartInfo.RedirectStandardError  = true;
            }

            // Start process
            context.EventLog.Verbose(context, "Starting process", new { File, Arguments });
            Verify.Assert <InvalidOperationException>(Process.Start(), "Could not start process");

            return(this);
        }