Question:
how do I execue a .bat from a powershell script.
I want to do something like:
1 2 3 4 5 6 7 8 9 |
foreach($item in $list){ param1= $item.Name param2= $item.path C:\Filesystem_Batches\test.bat param1 param2 } |
Thank you
Answer:
You can call
1 2 |
cmd.exe /C "test.bat param1 param2" |
In powershell V3 there is a new espace string –% which allow to send “weird” parameters to your exes.
exemple :
1 2 3 4 |
PS> echoargs.exe --% %USERNAME%,this=$something{weird} Arg 0 is |