C# Can';t从进程运行命令。启动
我可以从命令行运行此命令:C# Can';t从进程运行命令。启动,c#,.net,C#,.net,我可以从命令行运行此命令: C:\Windows\System32\rundll32.exe "C:\Program Files (x86)\Windows Photo Viewer\PhotoViewer.dll", ImageView_Fullscreen C:\Users\Public\Pictures\Sample Pictures\Chrysanthemum.jpg 图像打开没有问题 但是,当我尝试这样做时: exe = "C:\\Windows\\System32\\rundll
C:\Windows\System32\rundll32.exe "C:\Program Files (x86)\Windows Photo Viewer\PhotoViewer.dll", ImageView_Fullscreen C:\Users\Public\Pictures\Sample Pictures\Chrysanthemum.jpg
图像打开没有问题
但是,当我尝试这样做时:
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.Win32异常:系统找不到指定的文件
我尝试过在命令行和C#上使用引号,但两者都不能使用。根据我最近读到的答案,最后一部分不应该被引用
发生了什么事?结果是必须分别传递命令和参数:
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 Monitor查看找不到哪个指定的文件,这可能会给出提示。如果文件目录是URL形式的,那么这是否可行?@user1166085我不这么认为,备注部分:“如果要启动的可执行文件的地址是URL,则进程不会启动,并返回null。”