1

I am working on a batch script to read in some parameters and start a PowerShell script, which needs the typed in parameters.

What I have done so far:

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'";

Unfortunally the PowerShell script doesn't accept the parameters.

2
  • This question is already answered at SO. I would really follow the link of @deadlydog. His blog is very good.
    – Walter A
    Commented Apr 28, 2015 at 8:46
  • thanks, i will keep it in mind
    – Arturka1
    Commented Apr 28, 2015 at 8:54

2 Answers 2

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

Your variable names have a trailing space ("whatever<space>"). Lose the space before and after the equals sign:

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: 
1
  • Hardly my answer now?
    – Trigger
    Commented Apr 28, 2015 at 9:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.