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.

Ansgar Wiechers
  • 193,178
  • 25
  • 254
  • 328
Arturka1
  • 65
  • 1
  • 2
  • 11
  • This question is already answered at [SO](http://stackoverflow.com/questions/19335004/how-to-run-a-powershell-script-from-a-batch-file). I would really follow the link of @deadlydog. His [blog](http://blog.danskingdom.com/allow-others-to-run-your-powershell-scripts-from-a-batch-file-they-will-love-you-for-it/) is very good. – Walter A Apr 28 '15 at 08:46
  • thanks, i will keep it in mind – Arturka1 Apr 28 '15 at 08:54

2 Answers2

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: 
Ansgar Wiechers
  • 193,178
  • 25
  • 254
  • 328
Trigger
  • 681
  • 3
  • 4
2
PowerShell -NoProfile -ExecutionPolicy Bypass -file "%PowerShellScriptPath%" %arg1% %arg2% ....
Loïc MICHEL
  • 24,935
  • 9
  • 74
  • 103