Why can't I run the Snipping Tool from WPF?

I created a WPF window with a lot of buttons, each of which launches a different program. For example, to run MS Word, I used:

System.Diagnostics.Process.Start("C:\\Program Files (x86)\\Microsoft Office\\Office14\\WINWORD.EXE"); 

But when I try to run the Windows 7 Snipping Tool in the same way that it does not work. This was supposed to be as follows:

 System.Diagnostics.Process.Start("C:\\Windows\\System32\\SnippingTool.exe"); 

I am sure that the path is correct, but a message always appears stating that the file was not found. I would like to know why this is happening.

Important: I am using 64-bit versions of Windows 7.

+7
source share
3 answers

Use this:

 // if the build platform of this app is x86 use C:\windows\sysnative if(!Environment.Is64BitProcess) System.Diagnostics.Process.Start("C:\\Windows\\sysnative\\SnippingTool.exe"); else System.Diagnostics.Process.Start("C:\\Windows\\system32\\SnippingTool.exe"); 

The problem is your build platform (x86) and the automatic forwarding of the C:\Windows\System32\ on 64-bit OS.

Basically, for several reasons, in 64-bit Vista / Windows 7, when a 32-bit application tries to access C:\Windows\System32\ , it is automatically redirected to a folder named C:\Windows\SysWOW64\ . Therefore, you cannot run snippingtool.exe because it is not in this folder.

The only way is to use C:\Windows\sysnative\ and bypass the redirect.

+8
source

My psychic debugger tells me that you are using a 32-bit program on a 64-bit version of Windows, so your call to %WINDIR% ( C:\Windows ) will actually redirect to C:\Windows\SysWOW64 .

Use an environment variable instead of hardcoding paths to directories that may move depending on your environment and / or version of Windows.

+3
source

Instead, you should use an environment variable. You are probably running it on a 64-bit system, and C:\Windows\System32\ redirected.

+2
source

All Articles