You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

PowerShell脚本下载Adobe Acrobat安装包时文件损坏问题求助

解决PowerShell下载Adobe Acrobat Reader安装包仅得到4KB损坏文件的问题

问题原因

你使用的Adobe下载URL是跳转链接,Adobe服务器会根据请求的User-Agent头判断客户端类型:

  • 浏览器请求时,服务器会跳转到完整的安装包地址
  • PowerShell默认的User-Agent不是浏览器标识,服务器返回的是一个极小的引导程序/错误页面,导致下载的文件损坏无法使用

解决方案

通过模拟浏览器的User-Agent发送请求,让服务器返回正确的安装包跳转,同时自动跟随重定向获取实际安装包。

修改后的PowerShell脚本

$adobeInstallerUrl = "https://get.adobe.com/reader/download?os=Windows+10&name=Reader+2024.003.20112+English+Windows%2864Bit%29&lang=en&nativeOs=Windows+10&accepted=cr&declined=mss&preInstalled=&site=landing"
$installerPath = "C:\Users\User\Downloads\Reader_en_install.exe"

# 模拟Chrome浏览器的User-Agent
$userAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36"

function Download-AdobeInstaller {
    Write-Host "Downloading Adobe Acrobat Installer from $adobeInstallerUrl ..."
    try {
        # 添加User-Agent并跟随重定向(显式指定最大重定向次数)
        $response = Invoke-WebRequest -Uri $adobeInstallerUrl -OutFile $installerPath -UserAgent $userAgent -MaximumRedirection 10
        Write-Host "Download complete. Installer saved to $installerPath"
        Write-Host "实际下载地址: $($response.BaseResponse.ResponseUri.AbsoluteUri)"
    }
    catch {
        Write-Host "Failed to download Adobe Acrobat Installer. Error: $_"
        exit 1
    }
}

function Install-AdobeAcrobat {
    Write-Host "Running Adobe Acrobat installer..."
    try {
        Start-Process -FilePath $installerPath -ArgumentList "/sAll /rs /rps /msi EULA_ACCEPT=YES" -Wait -NoNewWindow
        Write-Host "Adobe Acrobat installation complete."
    }
    catch {
        Write-Host "Failed to install Adobe Acrobat. Error: $_"
        exit 1
    }
}

function Verify-FileSize {
    if (-not (Test-Path $installerPath)) {
        Write-Host "Installer file not found."
        exit 1
    }
    $file = Get-Item $installerPath
    # 完整Reader安装包通常大于150MB,设100MB作为最低阈值
    if ($file.Length -lt 104857600) { 
        Write-Host "The downloaded file is too small and might be corrupt. File size: $([math]::Round($file.Length / 1MB, 2)) MB"
        exit 1
    }
}

Download-AdobeInstaller
Verify-FileSize
Install-AdobeAcrobat

关键改动说明

  • 添加-UserAgent参数:模拟Chrome浏览器的请求标识,让Adobe服务器返回正确的安装包跳转地址
  • 优化Verify-FileSize:调整阈值为100MB(匹配Reader完整安装包实际大小),增加文件存在性检查
  • 给Start-Process添加-NoNewWindow:避免弹出额外命令行窗口
  • 输出实际下载地址:方便排查是否获取到正确的安装包链接

其他可选方法

如果上述方法仍有问题,可以手动获取实际安装包URL:

  1. 打开浏览器开发者工具(F12),切换到网络标签
  2. 在浏览器中访问你提供的Adobe下载URL,找到最终跳转到的.exe文件请求
  3. 复制该请求的URL,直接替换脚本中的$adobeInstallerUrl,此时无需模拟User-Agent即可下载

内容的提问来源于stack exchange,提问作者mwatson04

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.17 11:33:13