开发者

C# Process, unable to run exe that creates an Image and read it back

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 = ExePa开发者_C百科th.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?

C# Process, unable to run exe that creates an Image and read it back


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.

 <requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜