没有cmd.exe它应该通过process.start方法运行任何exe [英] without cmd.exe it should run any exe though process.start method

查看:158
本文介绍了没有cmd.exe它应该通过process.start方法运行任何exe的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我正在使用c#windows应用程序,我正在使用参数访问一个Exe(BatchRead.exe)。它能够通过cmd.exe-path-arguement访问,例如

语法。



代码:

Hello i am working on c# windows application, and i am accessing one Exe with arguments(BatchRead.exe). it is able to access through cmd.exe-path-arguement like
that syntax.

code:

var processInfo = new ProcessStartInfo("cmd.exe", "/k " + @"E:\Projects\ReadBatch\ReadBatch\bin\Release\ReadBatch.exe" + " " + currActionStep.Value + "@" + currActionStep.OutPut);
objProcess.StartInfo.RedirectStandardError = true;
           processInfo.UseShellExecute = false;
           objProcess.StartInfo = processInfo;
 objProcess.Start();





使用上面的代码,我们可以访问exe但它将通过cmd运行.exe。



但是,//预期代码



using above code we can able to access exe but it is going to run through cmd.exe.

But,//Expected code

var processInfo = new ProcessStartInfo(@"E:\Projects\ReadBatch\ReadBatch\bin\Release\ReadBatch.exe" + " " + currActionStep.Value + "@" + currActionStep.OutPut);





使用此代码它应该运行exe而不用cmd。



using this code it should run exe without cmd.

推荐答案

尝试使用两个字符串的构造函数:

Try the constructor that takes two strings:
var processInfo = new ProcessStartInfo(@"E:\Projects\ReadBatch\ReadBatch\bin\Release\ReadBatch.exe", currActionStep.Value + "@" + currActionStep.OutPut);


I认为问题是你将可执行文件和参数混合在一行上。只需在第一位有可执行文件,然后将参数粘贴在ProcessStartInfo的Arguments属性中。
I think the problem is you are mixing the executable and arguments all on one line. Just have the executable in the first bit, then stick the arguments in the "Arguments" property of ProcessStartInfo.


这篇关于没有cmd.exe它应该通过process.start方法运行任何exe的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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