Cannot start command from Process.Start

I can run this penalty from the command line:

C:\Windows\System32\rundll32.exe "C:\Program Files (x86)\Windows Photo Viewer\PhotoViewer.dll", ImageView_Fullscreen  C:\Users\Public\Pictures\Sample Pictures\Chrysanthemum.jpg

Image does not open.

However, when I try to do this:

exe = "C:\\Windows\\System32\\rundll32.exe \"C:\\Program Files (x86)\\Windows Photo Viewer\\PhotoViewer.dll\", ImageView_Fullscreen  C:\\Users\\Public\\Pictures\\Sample Pictures\\Chrysanthemum.jpg";
Process.Start(exe);

I get

System.ComponentModel.Win32Exception: the system cannot find the specified file

I tried with quotes both on the command line and in C # and did not work with them. According to the answer I recently read about SO, the last part should not be quoted.

What's happening?

+5
source share
1 answer

Turns off, you need to pass the command and arguments separately:

exe = "C:\\Windows\\System32\\rundll32.exe";
arguments = "\"C:\\Program Files (x86)\\Windows Photo Viewer\\PhotoViewer.dll\", ImageView_Fullscreen  C:\\Users\\Public\\Pictures\\Sample Pictures\\Chrysanthemum.jpg";
Process.Start(exe, arguments);
+13
source

All Articles