【发布时间】:2021-06-29 21:28:34
【问题描述】:
我试图创建一个从网站下载文件的批处理文件,在执行批处理文件后我发现了这个错误。
"Downloading CCleaner..."
Invoke-WebRequest : A positional parameter cannot be found that accepts argument '-'.
At line:1 char:1
+ Invoke-WebRequest https://download.ccleaner.com/ccsetup578.exe - Outf ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Invoke-WebRequest], ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
"Done!"
Press any key to continue . . .
下面是实际代码。
@echo off
echo "Downloading CCleaner..."
powershell -Command "Invoke-WebRequest https://download.ccleaner.com/ccsetup578.exe - Outfile setup.exe"
echo "Done!"
pause
【问题讨论】:
标签: powershell batch-file