Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c#

wpf

I've created a WPF Window with a lot of buttons, each of them run a different program. To run MS Word, for instance, 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 the same way it doesn't work. It was supposed to be like this:

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

I'm sure the path is correct, but always appears a message saying the file wasn't found. I would like to know why is this happening.

Important: I use Windows 7 64 bits.

like image 760
Rodrigo Guedes Avatar asked Jul 31 '12 17:07

Rodrigo Guedes


People also ask

Why is my Snipping Tool not opening?

Restart the Windows File Explorer As such, restarting File Explorer may dislodge whatever's keeping the Snipping Tool from working correctly. To do this, press Ctrl + Alt + Del, then select Task Manager. Alternatively, you can press CTRL + Shift + ESC to jump directly into the Task Manager.

How do I fix snip and sketch not working?

In some cases, when the snip and sketch app does not work, the issue can be related to the app's data on your system. In such a scenario, you will have to simply reset the application on your system which will delete the app's data on your system.


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 in your build platform (x86) and the automatic redirection of the folder C:\Windows\System32\ on 64-bit OS'es.

Basically, for several reasons, in vista/windows 7 64-bit OS'es when a 32 bit application try to access to C:\Windows\System32\ it is automatically redirected to the folder called C:\Windows\SysWOW64\. Hence, you cannot start snippingtool.exe because it is not present in that folder.

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

like image 177
digEmAll Avatar answered Sep 23 '22 02:09

digEmAll


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

Use the environment variable instead of hard-coding paths to directories that may move around depending on the environment and/or Windows version..

like image 31
Ed S. Avatar answered Sep 24 '22 02:09

Ed S.


You should use an environment variable instead. Likely you are running it on a 64 bit system and C:\Windows\System32\ is getting redirected.

like image 21
Daniel A. White Avatar answered Sep 25 '22 02:09

Daniel A. White