gpt4 book ai didi

powershell - Net.WebClient.DownloadFile从批处理文件下载Google云端硬盘文件无法识别某些字符

转载 作者:行者123 更新时间:2023-12-02 23:54:18 29 4
gpt4 key购买 nike

我正在尝试通过批处理文件并使用Net.WebClient.DownloadFile函数下载托管在Google云端硬盘上的文件,但这无法识别网址上存在的某些字符。

这是在控制台上收到的错误:

enter image description here

这是我最后的尝试:

    @echo off

SetLocal EnableExtensions EnableDelayedExpansion

set downloadurl="https://drive.google.com/uc?authuser=0&id=1gCLfIwL2FfswelXIsK6tkWm5kCRSTNh8&export=download"
set downloadpath=%LOCALAPPDATA%\test.txt

powershell -command "& { (New-Object Net.WebClient).DownloadFile('%downloadurl%', '%downloadpath%'); }"

pause

我该如何解决?

提前致谢。

最佳答案

SET语句中的引号由cmd解释,因此它会尝试继续解释并被单引号引起混淆。这样更改代码:

@ECHO OFF

SET "downloadurl=https://drive.google.com/uc?authuser=0&id=1gCLfIwL2FfswelXIsK6tkWm5kCRSTNh8&export=download"

powershell.exe -Command "Invoke-WebRequest -Uri %downloadurl% -OutFile $Env:LocalAppData\test.txt"

PAUSE

关于powershell - Net.WebClient.DownloadFile从批处理文件下载Google云端硬盘文件无法识别某些字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49212587/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com