將 CMD 參數傳遞給 Powershell

你好西比利

這裡的代碼:

@echo off
if "%*"=="" (echo Give me the URL! && exit /b)
echo Output :
set /p output=
powershell Invoke-WebRequest -Uri %* -OutFile output

我寫的這段代碼中的問題是輸出變量
如何將該變量發送到 powershell 中?

馬蒂亞斯·R·傑森

使用%output%擴展output變量-記住引用的論據(否則它會打破,如果有人輸入,空格的路徑):

@echo off
if "%*"=="" (echo Give me the URL! && exit /b)
echo Output :
set /p output=
powershell Invoke-WebRequest -Uri '%*' -OutFile '%output%'

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章