2016-07-30 5 views
2

이것은 제가 직면 한 바보 같은 까다로운 문제입니다.Process.Start in C# 지정한 파일을 찾을 수 없습니다.

아래의 코드는 (은 계산기를 실행) 잘 작동 :

ProcessStartInfo psStartInfo = new ProcessStartInfo(); 
psStartInfo.FileName = @"c:\windows\system32\calc.exe"; 

Process ps = Process.Start(psStartInfo); 

SoundRecorder에 대한 아래 하나가 작동하지 않습니다 그러나

. 그것은 나에게 "시스템은 지정된 파일을 찾을 수 없습니다"오류를 제공합니다.

ProcessStartInfo psStartInfo = new ProcessStartInfo(); 
psStartInfo.FileName = @"c:\windows\system32\soundrecorder.exe"; 

Process ps = Process.Start(psStartInfo); 

시작 -> 실행 -> "c : \ windows \ system32 \ soundrecorder.exe"명령을 사용하여 사운드 레코더를 시작할 수 있습니다.

어떤 아이디어가 잘못 되었나요?

Visual Studio 2015 및 Windows 7 OS에서 C#을 사용하고 있습니다. UPDATE 1

이 : 나는 File.Exists 확인을 시도하고 아래의 코드에서 나에게 메시지 박스를 보여줍니다

if (File.Exists(@"c:\windows\system32\soundrecorder.exe")) 
{ 
    ProcessStartInfo psStartInfo = new ProcessStartInfo(); 
    psStartInfo.FileName = @"c:\windows\system32\soundrecorder.exe"; 

    Process ps = Process.Start(psStartInfo); 
} 
else 
{ 
    MessageBox.Show("File not found"); 
} 
+0

safetey의 경우 경로를 올바르게 사용하십시오. ''C : \ Windows \ system32 \ soundrecorder.exe "'를 입력하십시오. 탐색기에서 파일이 있는지 확인 했습니까? 'System.IO '의'File.Exists()'는 무엇을 말하는가? –

+0

두 코드가 모두 제대로 작동합니다. –

+0

프로세스를 시작하기 전에'if (File.Exists (@ "c : \ windows \ system32 \ soundrecorder.exe")'를 사용하여 파일이 있는지 확인하십시오. – Nkosi

답변

7

대부분의 경우 귀하의 응용 프로그램입니다 32 비트 및 C:\Windows\System32 64 비트 Windows 참조에 GET 32 비트 앱의 경우 투명하게 C:\Windows\SysWOW64으로 리디렉션되었습니다. calc.exe은 두 위치 모두에 존재하지만 soundrecorder.exe은 사실 System32에만 있습니다.

Start/Run에서 시작하면 부모 프로세스는 64 비트 explorer.exe이므로 리디렉션이 수행되지 않고 64 비트 C:\Windows\System32\soundrecorder.exe이 발견되어 시작됩니다. File System Redirector에서

:

대부분의 경우, 32 비트 응용 프로그램을 % windir % \ system32를 액세스하려고 시도 할 때마다이 액세스는을 % windir % \ SysWOW64와로 리디렉션됩니다.


[편집] 같은 페이지에서 :

32 비트 응용 프로그램을 % windir % \ system32를 위해 \ %의 % windir을 대체하여 Sysnative를 기본 시스템 디렉토리에 액세스 할 수 있습니다.

따라서 다음은 (실제) C:\Windows\System32에서 soundrecorder.exe을 시작하는 데 적합합니다.

psStartInfo.FileName = @"C:\Windows\Sysnative\soundrecorder.exe"; 
+0

흥미 롭습니다! 여기서 해결 방법은 무엇입니까? 내 C#에서 내장 사운드 레코더 응용 프로그램을 실행하고 싶습니다. – kamleshrao

+1

SYSNATIVE 트릭이 작동했습니다! 도움을 주셔서 감사합니다. – kamleshrao

+0

SYSNATIVE 설명서에 대해 설명하는 Microsoft KB 기사가 있습니다. https://support.microsoft.com/en-us/kb/942589 – kamleshrao

관련 문제