Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/257.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
使用批处理脚本中的参数运行PowerShell脚本_Powershell_Batch File - Fatal编程技术网

使用批处理脚本中的参数运行PowerShell脚本

使用批处理脚本中的参数运行PowerShell脚本,powershell,batch-file,Powershell,Batch File,我正在编写一个批处理脚本,以读入一些参数并启动PowerShell脚本,该脚本需要键入的参数 到目前为止我所做的: Set /p arg1 = Type in a name for the data: Set /p arg2 = Type in the directory of the project: Set /p arg3 = Type in the programming language : Set /p arg4 = Type in a version for the m

我正在编写一个批处理脚本,以读入一些参数并启动PowerShell脚本,该脚本需要键入的参数

到目前为止我所做的:

Set /p arg1 = Type in a name for the  data: 

Set /p arg2 = Type in the directory of the project: 

Set /p arg3 = Type in the programming language : 

Set /p arg4 = Type in a version for the metric data: 

SET ThisScriptsDirectory=%~dp0
SET PowerShellScriptPath=%ThisScriptsDirectory%Metrics.ps1

PowerShell -NoProfile -ExecutionPolicy Bypass -Command "& '%PowerShellScriptPath%' 'arg1' 'arg2' 'arg3' 'arg4'";

不幸的是,PowerShell脚本不接受这些参数。

您的变量名后面有一个空格(“随便什么”)。失去等号前后的空格:

Set /p arg1=Type in a name for the  data: 
Set /p arg2=Type in the directory of the project: 
Set /p arg3=Type in the programming language : 
Set /p arg4=Type in a version for the metric data: 

变量名后面有一个空格(“随便什么”)。失去等号前后的空格:

Set /p arg1=Type in a name for the  data: 
Set /p arg2=Type in the directory of the project: 
Set /p arg3=Type in the programming language : 
Set /p arg4=Type in a version for the metric data: 

这个问题已经在第页得到了回答。我真的会关注@deadlydog的链接。他的回答很好。谢谢,我会记住的。这个问题已经在回答了。我真的会关注@deadlydog的链接。他的回答很好。谢谢,我会记在心里的现在几乎没有我的答案?现在几乎没有我的答案?