Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Powershell 尝试从网站下载文件时发现我的批处理文件出错_Powershell_Batch File - Fatal编程技术网

Powershell 尝试从网站下载文件时发现我的批处理文件出错

Powershell 尝试从网站下载文件时发现我的批处理文件出错,powershell,batch-file,Powershell,Batch File,我试图创建一个从网站下载文件的批处理文件,在执行批处理文件后,我发现了这个错误 "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

我试图创建一个从网站下载文件的批处理文件,在执行批处理文件后,我发现了这个错误

"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
删除“-”和“OutFile”之间的空格


您好,它适用于我的Windows 10,但不适用于Windows Server 2016。可能是什么问题?第一次以用户身份打开web浏览器时,您必须接受Internet Explorer提示,这也适用于运行
Invoke WebRequest
。您应该得到的提示应为“无法分析响应内容,因为Internet Explorer引擎不可用,或者Internet Explorer的首次启动配置不完整。”。指定UseBasicParsing参数并重试。`您可以通过将
-UseBasicParsing
添加到
调用WebRequest
行来解决此问题。我尝试在它旁边替换和添加。没有工作。请告诉我们您当前的代码和错误消息好吗?
@echo off
echo "Downloading CCleaner..."
powershell -Command "Invoke-WebRequest https://download.ccleaner.com/ccsetup578.exe -Outfile setup.exe"
echo "Done!"
pause