2013-02-04 7 views
0

나는 다음과 같은 코드가 있습니다 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을 실행하면 정상적으로 작동합니다. 왜 코드로 프로세스를 시작할 때이 오류가 발생하지만 명령 행에서는 그렇지 못합니까?

답변

0

에 한번 여기서 "w32tm"을 찾기 위해,

procStartInfo.UseShellExecute = true; 

당신은 지정하지 않은 사용, 그래서 아마 파일을 찾을 수 없습니다. 나는 당신이 그것의 전체 경로와 확장, 또는 UseShellExecute를 제공해야한다고 생각한다.

현재 : 일부 속성은 코드에서 두 번 설정됩니다. ;-)

+0

UserShellExecute 인 경우 표준 출력을 리디렉션 할 수 없습니다. 그게 내가 뭘 할 수 있을까 ?? –

+0

그런 다음 전체 경로와 파일 이름을 확장자로 지정하십시오. 예 : "C : \ Windows \ System32 \ W32tm.exe" – Fischermaen

+0

또한, 나는 여전히 동일한 오류가 발생했습니다. –

0

DependencyWalker 도구를 사용하여 누락 된 모듈을 찾고 검색 PATH에서 찾을 수 없습니다. UseShellExecute을 true로 설정하는 것이 도움이 될 수 있습니다. 거짓으로 설정하는 이유는 무엇입니까?

관련 문제