如何在 processStartInfo 中传递多个参数? [英] How to pass multiple arguments in processStartInfo?
问题描述
我想从 c#
代码运行一些 cmd
命令.我关注了一些博客和教程并得到了答案,但我有点困惑,即我应该如何传递多个参数?
I want to run some cmd
command from c#
code. I followed some blogs and tutorial and got the answer, but I am in little bit confused i.e how should I pass multiple arguments?
我使用以下代码:
System.Diagnostics.Process process = new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal;
startInfo.FileName = "cmd.exe";
startInfo.Arguments =
...
以下命令行代码的 startInfo.Arguments
值是什么?
What will be the startInfo.Arguments
value for the following command line code?
makecert -sk server -sky exchange -pe -n CN=localhost -ir LocalMachine -is Root -ic MyCA.cer -sr LocalMachine -ss MyAdHocTestCert.cer
netsh http add sslcert ipport=127.0.0.1:8085 certhash=0000000000003ed9cd0c315bbb6dc1c08da5e6 appid={00112233-4455-696977-4455-696977-80000000000003ed9cd0c315bbb6dc1c08da5e6 appid={00112233-4455-696977-4455-896977-80000000000003>
推荐答案
纯粹是一个字符串:
startInfo.Arguments = "-sk server -sky exchange -pe -n CN=localhost -ir LocalMachine -is Root -ic MyCA.cer -sr LocalMachine -ss My MyAdHocTestCert.cer"
当然,当参数包含空格时,您必须使用 " " 将它们转义,例如:
Of course, when arguments contain whitespaces you'll have to escape them using " ", like:
"... -ss "My MyAdHocTestCert.cer""
请参阅 MSDN 为此.
这篇关于如何在 processStartInfo 中传递多个参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!