나는 과정을 만들려면 다음 라인을 사용 : 여기에 몇 가지 명령을C# 호출 배치
process.StartInfo.FileName = "cmd.exe";
process.StartInfo.WorkingDirectory = buildProject.DirectoryName;
process.StartInfo.UseShellExecute = false;
process.StartInfo.CreateNoWindow = true;
process.StartInfo.RedirectStandardInput = true;
process.StartInfo.RedirectStandardOutput = true;
가 그럼 난 프로세스를 시작하고 전달합니다
process.Start();
StreamWriter stream = process.StandardInput;
// call batch
stream.WriteLine(@"call ""test.bat""");
// call exe
stream.WriteLine("echo msbuild!");
// exit-command
stream.WriteLine("exit");
프로세스가 immediatly 정지이 경우
@call :Jump_1
@call :Jump_2
@goto end
@REM -----------------------------------------------------------------------
:Jump_1
@echo Jump_1
@call :Jump_1_1 1>nul 2>&1 REM critical!!!
@exit /B 0
:Jump_1_1
@echo Jump_1_1
@exit /B 0
@REM -----------------------------------------------------------------------
:Jump_2
@echo Jump_2
@call :Jump_2_1 1>nul 2>&1 REM critical!!!
@exit /B 0
:Jump_2_1
@echo Jump_2_1
@exit /B 0
@REM -----------------------------------------------------------------------
@echo End
:end
다음 배치 파일은 두 NUL-리디렉션을 포함 할 때까지
모든 잘 작동합니다. StandardOut이 보여줍니다
,536,마이크로 소프트 윈도우 XP [버전 5.1.2600]
(C) 저작권 1,985에서 2,001 사이 마이크로 소프트
C : \ ENTWICKLUNG \ ProcessTest \ ProcessTest \ 빈 \ 디버그> 전화 "TEST.BAT"
Jump_1
Jump_2
모두 제거하면 리디렉션이 두 개있는 경우에만 충돌이 발생합니다.
원본 스크립트가 VS2010과 함께 제공되기 때문에 스크립트를 변경할 수 없습니다.
편집 : 질문을 자세히 업데이트했습니다.
cmd.exe 대신 프로세스로 .bat 파일을 시작하면 작동하지 않습니까? –
아니요 ... 동일한 문제 ... StandardInput을 사용하지 않도록 설정 한 경우에도 – lippo
nul에 대한 리디렉션이 실패하거나 stderror에서 stdout ('2> & 1')로 리디렉션됩니까? 코드가 RedirectStandardError를 true로 설정하지 않았습니다 ... –