Reputation: 7039
I have a file hello.bat
with the following code:
echo first: %1 and second: %2 > me.txt
I am trying to call this using powershell. When I pass the first parameter it works well:
start-process hello test
However when i try to pass the second parameter like this:
start-process hello test test2
I get this error:
Start-Process : A positional parameter cannot be found that accepts argument 'test2'
Upvotes: 1
Views: 734
Reputation: 5242
I don't know why you're starting a command line from a command line but I think this should work:
Start-Process -FilePath $env:ComSpec -ArgumentList "/c hello.bat test test2"
Don't you think it's time to replace cmd with Powershell?
You might change your bat file as well:
echo %1 > me.txt
echo %2 >> me.txt
Upvotes: 0