无法从运行的Process.Start命令 [英] Can't run command from Process.Start

查看:289
本文介绍了无法从运行的Process.Start命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以在命令行中运行此罚款:

I can run this fine 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 opens no problem.

然而,当我试着这样做:

However, when I try and 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);

我收到了

System.ComponentModel.Win32Exception:系统找不到指定文件

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

我试图与这两个命令行和C#,并没有工作,他们的报价。据一个答案我读的SO最近半句不应该被引用。

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

这是怎么回事?

推荐答案

原来一个人单独传递命令和参数:

Turns out one has 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);

这篇关于无法从运行的Process.Start命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆