PowerShell WebClient.DownloadFile() 在下载几秒钟后停止



这个程序应该将两个文件下载到一个目录中,但是当我运行该程序时,第一个20KB下载,但随后它停止了。

这是我的代码:

$javaURL = "https://download.oracle.com/otn-pub/java/jdk/14.0.1+7/664493ef4a6946b186ff29eb326336a2/jdk-14.0.1_windows-x64_bin.exe"
$eclipseURL = "https://www.eclipse.org/downloads/download.php?file=/oomph/epp/2020-03/R/eclipse-inst-win64.exe&mirror_id=1099"
$outpathJava = "C:myPathfile1.exe"
$outpathEclipse = "C:myPathfile.exe"
$webClient = New-Object System.Net.WebClient
$webClient.DownloadFile($javaURL, $outpathJava)
$webClient.DownloadFile($eclipseURL, $outpathEclipse)

如果您使用浏览器导航到刚刚共享的链接,您将看到这些链接不是可执行文件。

对于 Java,如果作为文本文件 file1 打开.exe您将看到类似以下内容的内容:

<html>
<head>
<title>Unauthorized Request</title>
<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
<link rel="stylesheet" type="text/css" href="/errors/us/assets/hp-styles.css" />
<link rel="stylesheet" type="text/css" href="/errors/us/assets/master-master.css" />
<body style="margin: 0px" bgcolor=#ffffff>
<div id="banner">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td rowspan="2" valign="middle" nowrap><a href="http://www.oracle.com"><img src="/errors/us/assets/oralogo-small.gif" width="154" height="19" hspace="10" vspace="25" border="0" ></a></td>
<td align="right" valign="top" width="70%" nowrap class="padMid"><div id="bannerMid"> </div></td>
<td width="30%" align="left" valign="bottom" nowrap></td>
</tr>
<tr>
<td align="right" valign="bottom" nowrap class="padMid"></td>
<td width="30%" align="left" valign="bottom" nowrap></td>
</tr>
</table>
</div>
<!-- Header END //-->
<table  BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH="100%">
...

日食链接类似。

我建议你可能使用巧克力来安装软。

日蚀 爪哇岛

安装巧克力:https://chocolatey.org/install

然后在作为PowerShell(作为管理员(中:

choco install eclipse

最新更新