使用批处理脚本

时间:2015-04-28 08:32:25

标签: 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 metric data: 

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

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

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

2 个答案:

答案 0 :(得分:2)

您的变量名称有一个尾随空格(“whatever< space>”)。失去等号前后的空格:

<span>{{???}} Count of Read Emails</span>
<span>{{???}} Count of Unread Emails</span>

答案 1 :(得分:2)

PowerShell -NoProfile -ExecutionPolicy Bypass -file "%PowerShellScriptPath%" %arg1% %arg2% ....