powershell - 批量隐藏Invoke-WebRequest

标签 powershell shell batch-file

我正在尝试在.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/

相关文章:

linux - 如何使用 bash 从字符串中提取字段

shell - 使用 sed 在匹配后插入行

windows - 如何将文件内容转换为cmd中的安全字符串?

windows - 嵌套文件 : path and extension filter

powershell - 处理 Power-Shell JSON 对象中的日期

python - Powershell-将两个管道合并为一个

javascript - shell 中的 Rhino 1.7 不映射历史记录的方向键

windows - 在断开连接的共享目录中检查文件时避免长时间延迟

Powershell:如何从另一个静态方法调用静态方法

xml - 在Powershell中解析XML