gpt4 book ai didi

c# - 如何在 processStartInfo 中传递多个参数?

转载 作者:IT王子 更新时间:2023-10-29 04:09:27 28 4
gpt4 key购买 nike

我想从 c# 代码运行一些 cmd 命令。我按照一些博客和教程得到了答案,但我有点困惑,即我应该如何传递多个参数?

我使用以下代码:

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 值是多少?

  • 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-6677-8899-AABBCCDDEEFF} clientcertnegotiation=enable

最佳答案

它是一个纯粹的字符串:

startInfo.Arguments = "-sk server -sky exchange -pe -n CN=localhost -ir LocalMachine -is Root -ic MyCA.cer -sr LocalMachine -ss My MyAdHocTestCert.cer"

当然,当参数包含空格时,您必须使用\"\"将它们转义,例如:

"... -ss \"My MyAdHocTestCert.cer\""

参见 MSDN为此。

关于c# - 如何在 processStartInfo 中传递多个参数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15061854/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com