나는 다음과 같은 코드가 있습니다 System.Diagnostics.Process : 지정한 모듈을 찾을 수 없습니다. (0x8007007e가)
// Creating procesStartInfo obj
System.Diagnostics.ProcessStartInfo procStartInfo
= new System.Diagnostics.ProcessStartInfo();
procStartInfo.RedirectStandardOutput = true;
procStartInfo.UseShellExecute = false;
// Do not create the black window.
procStartInfo.CreateNoWindow = true;
//Window state hidden .. so black windows will come inbetween
procStartInfo.WindowStyle
= System.Diagnostics.ProcessWindowStyle.Hidden;
// Creating Process obj to run the net time cmd
System.Diagnostics.Process p;
string output;
p = new System.Diagnostics.Process();
p.StartInfo = procStartInfo;
p.StartInfo.FileName = "w32tm";
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.Arguments = " /resync /computer:xxxxx977";
p.Start();
p.WaitForExit();
output = p.StandardOutput.ReadLine().ToString();
MessageBox.Show(output);
이 코드를 실행
, 나는 오류 메시지가 점점 오전 :다음 오류가 발생했습니다 : 지정된 모듈을 찾을 수 없습니다. (0x8007007E).
원격으로 또는 로컬로 명령 w32tm /resync /computer:xxxxx977
을 실행하면 정상적으로 작동합니다. 왜 코드로 프로세스를 시작할 때이 오류가 발생하지만 명령 행에서는 그렇지 못합니까?
UserShellExecute 인 경우 표준 출력을 리디렉션 할 수 없습니다. 그게 내가 뭘 할 수 있을까 ?? –
그런 다음 전체 경로와 파일 이름을 확장자로 지정하십시오. 예 : "C : \ Windows \ System32 \ W32tm.exe" – Fischermaen
또한, 나는 여전히 동일한 오류가 발생했습니다. –