C# 通过Process.Start将多个参数传递到powershell文件
我在为powershell文件传递多个参数以通过Process.Start运行时遇到问题。这就是我目前所拥有的C# 通过Process.Start将多个参数传递到powershell文件,c#,powershell,process.start,C#,Powershell,Process.start,我在为powershell文件传递多个参数以通过Process.Start运行时遇到问题。这就是我目前所拥有的 strCmdText = "/c powershell.exe -file " + filePath + " " + configs[i].name + " " + configs[i].path + "/" + configs[i].extension + &quo
strCmdText = "/c powershell.exe -file " + filePath + " " + configs[i].name + " " + configs[i].path + "/" + configs[i].extension + " " + configs[i].value;
System.Diagnostics.Process pro = System.Diagnostics.Process.Start("cmd.exe", strCmdText);
我发现了许多示例,可以演示如何通过此命令执行powershell文件,但从来没有任何一个具有多个参数的示例,我假设是这样的,但命令无法正常工作。您使用的是“开始信息”。命令行是一个类似于-a-b-c的字符串。然后在power shell中,它与从命令窗口运行相同,参数带有美元符号。为什么要使用
cmd.exe
执行powershell.exe
?为什么不直接运行powershell.exe
?是否在args之后而不是之前尝试了-file标志?文件路径是什么?脚本powershell?如果是powershell脚本,您是否可以使用param的定义显示脚本的开头