C# 进程,无法运行创建图像并将其读回的 exe
我正在尝试从 C# 运行 exe
ProcessStartInfo si = new ProcessStartInfo
(
ExePath, InputImageFilePath +" "+
numericUpDownResize.Value +" "+
numericUpDownPad.Value+" "+
numericUpDownWindow.Value
);
si.UseShellExecute = true;
si.CreateNoWindow = true;
si.WindowStyle = ProcessWindowStyle.Normal;
si.Verb = "runas";
Process process = Process.Start(si);
process.WaitForExit();
int indexOfLastSlash = ExePath.LastIndexOf(@"\");
string outputFilePath = ExePath.Substring(0, indexOfLastSlash);
OutputImage = new Bitmap(outputFilePath + @"\output.jpg");
当我从命令行提示符运行 exe 时,它按预期工作正常,并且创建了 JPEG。但是当我尝试 C# 程序时,在通过 UAC 允许程序运行一次后,我看到命令行提示符打开并显示状态。但没有产生输出图像。
有什么我想念的吗?
更新
按照 Moxplod 的建议添加清单后,我正在检查安全设置。我显示的突出显示的框是否需要像其他几个一样被选中为绿色?
I am trying to run an exe from C#
ProcessStartInfo si = new ProcessStartInfo
(
ExePath, InputImageFilePath +" "+
numericUpDownResize.Value +" "+
numericUpDownPad.Value+" "+
numericUpDownWindow.Value
);
si.UseShellExecute = true;
si.CreateNoWindow = true;
si.WindowStyle = ProcessWindowStyle.Normal;
si.Verb = "runas";
Process process = Process.Start(si);
process.WaitForExit();
int indexOfLastSlash = ExePath.LastIndexOf(@"\");
string outputFilePath = ExePath.Substring(0, indexOfLastSlash);
OutputImage = new Bitmap(outputFilePath + @"\output.jpg");
When I run the exe from command line prompt, it works fine as expected and the JPEG is created. But when I try the C# program, after allowing the program run once through UAC, I see the command line prompt open and display the status. But the output image is not produced.
Is there something that I miss?
Update
After adding the Manifest as suggested by Moxplod, I was going through the security settings. Does the highlighted box I have shown need to be checked green like the other few?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
程序是否在当前目录中生成输出图像?因为您正在检查包含可执行文件的目录中的图像,该可执行文件可能与当前目录不同。
Does program produce output image in the current directory? Because you are checking for image in the directory that contains executable which may be different from current directory.
您可以添加清单条目,这样就不会出现权限错误。如果这就是你想要的。
You can add a manifest entry so you dont get permission errors. If this is what you want.