private void CreateTaskScriptFile() { using (var script = new StreamWriter(Path.Combine(TaskFolderPath, StartScriptFilename), false)) { script.WriteLine("@ECHO OFF"); if (RedirectOutputToFiles) { script.WriteLine("SET scriptOutPath=" + OutputFilePath); script.WriteLine("SET scriptErrPath=" + ErrorFilePath); } // Since the Task folder where the script file is created may be // different than the preferred working directory of the executable // we always set this. script.WriteLine("PUSHD " + WorkingDirectory); WritePreExecutableScript(script); string executableCmdLine = CommandlineUtil.ComposeCommandline(ExecutableFilePath, GetExecutableArguments()); script.Write(executableCmdLine); if (RedirectOutputToFiles) { script.Write(" 1>\"%scriptOutPath%\""); script.Write(" 2>\"%scriptErrPath%\""); } script.WriteLine(); } }
protected virtual ProcessStartInfo CreateProcessStartInfo() { return(new ProcessStartInfo(ExecutableFilePath) { Arguments = CommandlineUtil.ComposeCommandlineArguments(GetExecutableArguments()), WorkingDirectory = TaskFolderPath, // The script should always start locally // NOTE: This assumes the process is a script or command-line executable. CreateNoWindow = true, UseShellExecute = false, }); }