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. Commented Apr 28, 2015 at 8:46
  • thanks, i will keep it in mind Commented Apr 28, 2015 at 8:54

2 Answers 2

2
PowerShell -NoProfile -ExecutionPolicy Bypass -file "%PowerShellScriptPath%" %arg1% %arg2% ....
Sign up to request clarification or add additional context in comments.

Comments

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 Comment

Hardly my answer now?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.