我正在尝试在.bat文件中下载一个exe,但是无法隐藏输出$progressPreference = 'silentlyContinue'
| Out-Null
和$null 2>&1.
我不知道为什么他们都不起作用。
这是我正在使用的脚本。
powershell "Invoke-WebRequest http://example.com/example.exe -OutFile "%UserProfileDir%\AppData\LocalLow\example_Data\example.exe"
它完美地下载了exe,但我无法隐藏输出。
最佳答案
您可以从此批处理文件中获得启发:
@echo off
set URL=https://www.google.tn/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png
set FileName=%~dp0Google_Logo.png
Call :Download %URL% %FileName%
Start "" %FileName% & Exit
::*********************************************************************************
:Download <URL> <FILE>
Powershell.exe -command "(New-Object System.Net.WebClient).DownloadFile('%1','%2')"
exit /b
::*********************************************************************************
关于powershell - 批量隐藏Invoke-WebRequest,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60013048/