Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 通过Process.Start将多个参数传递到powershell文件_C#_Powershell_Process.start - Fatal编程技术网

C# 通过Process.Start将多个参数传递到powershell文件

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

我在为powershell文件传递多个参数以通过Process.Start运行时遇到问题。这就是我目前所拥有的

                    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的定义显示脚本的开头