草庐IT

windows - 下载VBS错误 "(null): 0x80072EE6"

coder 2024-06-14 原文

我有this用于下载文件的VBS:

Set args = Wscript.Arguments

downloadURL = WScript.Arguments.Item(0)
saveLocation = WScript.Arguments.Item(1)

dim xHttp: Set xHttp = createobject("Microsoft.XMLHTTP")
dim bStrm: Set bStrm = createobject("Adodb.Stream")
xHttp.Open "GET", downloadURL, False
xHttp.Send

with bStrm
    .type = 1 '//binary
    .open
    .write xHttp.responseBody
    .savetofile saveLocation, 2 '//overwrite
end with

和这个批处理文件 ( pastebin ),它应该下载一堆文件并解压缩压缩文件:

@echo off

setlocal EnableDelayedExpansion

rem Set the output directory
set output=Plugins

rem Set the directory name that will be used when unzipping files
set zip_temp=Temp

rem set the path to the download vbs
set dl_vbs=Resources\dl.vbs

rem Set the name for the zip extractor VBS
set zip_vbs=Resources\extract.vbs

rem set date_time to Year-Month-Day_HourH-MinuteM
for /F "usebackq tokens=1,2 delims==" %%i in (`wmic os get LocalDateTime /VALUE 2^>NUL`) do if '.%%i.'=='.LocalDateTime.' set DATETIME_VAR=%%j
set date_time=%DATETIME_VAR:~0,4%-%DATETIME_VAR:~4,2%-%DATETIME_VAR:~6,2%_%DATETIME_VAR:~8,2%H-%DATETIME_VAR:~10,2%M

echo Deleting old log files...
rem Remember to keep this updated with %date_time%!
del Log_*-*-*_*H-*M.txt
echo Done.
echo.

rem Set the log file name
set log=Log_%date_time%.txt

> %log% echo -- Log --
>>%log% echo.

rem Empty the output folder
echo Deleting + replacing output (%output%)...
if NOT "%output%"=="." (
    if exist %output% rd /s /q %output%
    md %output%
)
echo Done.
>>%log% echo Output folder "%output%" Deleted and remade.
>>%log% echo.
echo.

rem Could be latest verison (latest) or beta version (beta). Or, release version (release).
rem ( See: https://bukkit.org/threads/uniform-links-to-latest-version.118175/ post #10 )
set type=latest

rem Start the counter at 1
set /a plugin_counter=1

rem download_index = word used in the URL for downloading the file
rem desired_name = name of the plugin; name of the finished downloaded file
rem download_location = an alternate URL if the global one doesn't work
rem zip_location = the name of the jar file in the zip if the download file is a zip rather than jar
rem plugin_disabled_reason = the reason that this particular plugin is not to be downloaded at all

set download_index[!plugin_counter!]=afkterminator
set desired_name[!plugin_counter!]=AFK-Terminator
set download_location[!plugin_counter!]=bukget
set /a plugin_counter+=1

set download_index[!plugin_counter!]=autorefill
set desired_name[!plugin_counter!]=AutoRefill
set zip_location[!plugin_counter!]=AutoRefill.jar
set download_location[!plugin_counter!]=bukget
set /a plugin_counter+=1

set download_index[!plugin_counter!]=autosaveworld
set desired_name[!plugin_counter!]=AutoSaveWorld
set download_location[!plugin_counter!]=bukget
set /a plugin_counter+=1

set download_index[!plugin_counter!]=compatnocheatplus-cncp
set desired_name[!plugin_counter!]=CompatNoCheatPlus
set download_location[!plugin_counter!]=bukget
set /a plugin_counter+=1

set download_index[!plugin_counter!]=commandlog
set desired_name[!plugin_counter!]=CommandLog
set download_location[!plugin_counter!]=bukget
set /a plugin_counter+=1

set download_index[!plugin_counter!]=coreprotect
set desired_name[!plugin_counter!]=CoreProtect
set download_location[!plugin_counter!]=bukget
set /a plugin_counter+=1

set download_index[!plugin_counter!]=cshortcut
set desired_name[!plugin_counter!]=C-Shortcut
set download_location[!plugin_counter!]=bukget
set /a plugin_counter+=1

set download_index[!plugin_counter!]=deathcontrol
set desired_name[!plugin_counter!]=DeathControl
set download_location[!plugin_counter!]=bukget
set /a plugin_counter+=1

set download_index[!plugin_counter!]=disable-respawn-screen
set desired_name[!plugin_counter!]=DisableRespawnScreen
set download_location[!plugin_counter!]=bukget
set /a plugin_counter+=1

set download_index[!plugin_counter!]=dropswap
set desired_name[!plugin_counter!]=DropSwap
set download_location[!plugin_counter!]=bukget
set /a plugin_counter+=1

set download_index[!plugin_counter!]=emp
set desired_name[!plugin_counter!]=EnjinMinecraftPlugin
set download_location[!plugin_counter!]=bukget
set /a plugin_counter+=1

set download_index[!plugin_counter!]=essentials
set desired_name[!plugin_counter!]=Essentials
set zip_location[!plugin_counter!]=target\*
set download_location[!plugin_counter!]=https://hub.spigotmc.org/jenkins/job/Spigot-Essentials/lastSuccessfulBuild/artifact/Essentials/target/*zip*/target.zip
set /a plugin_counter+=1

set download_index[!plugin_counter!]=essentialschat
set desired_name[!plugin_counter!]=EssentialsChat
set zip_location[!plugin_counter!]=target\*
set download_location[!plugin_counter!]=https://hub.spigotmc.org/jenkins/job/Spigot-Essentials/lastSuccessfulBuild/artifact/EssentialsChat/target/*zip*/target.zip
set /a plugin_counter+=1

set download_index[!plugin_counter!]=essentialsspawn
set desired_name[!plugin_counter!]=EssentialsSpawn
set zip_location[!plugin_counter!]=target\*
set download_location[!plugin_counter!]=https://hub.spigotmc.org/jenkins/job/Spigot-Essentials/lastSuccessfulBuild/artifact/EssentialsSpawn/target/*zip*/target.zip
set /a plugin_counter+=1

set download_index[!plugin_counter!]=factions
set desired_name[!plugin_counter!]=Factions
set download_location[!plugin_counter!]=bukget
set /a plugin_counter+=1

set download_index[!plugin_counter!]=frameprotect
set desired_name[!plugin_counter!]=FrameProtect
set download_location[!plugin_counter!]=bukget
set zip_location[!plugin_counter!]=FrameProtect.jar
set /a plugin_counter+=1

set download_index[!plugin_counter!]=frameprotect
set desired_name[!plugin_counter!]=FrameProtectDatabaseUpdater
set download_location[!plugin_counter!]=bukget
set zip_location[!plugin_counter!]=FrameProtectDatabaseUpdater.jar
set /a plugin_counter+=1

set download_index[!plugin_counter!]=global-market
set desired_name[!plugin_counter!]=GlobalMarket
set download_location[!plugin_counter!]=bukget
set /a plugin_counter+=1

set download_index[!plugin_counter!]=insanemobs
set desired_name[!plugin_counter!]=InsaneMobs
set download_location[!plugin_counter!]=bukget
set /a plugin_counter+=1

set download_index[!plugin_counter!]=magicloot
set desired_name[!plugin_counter!]=MagicLoot
set download_location[!plugin_counter!]=bukget
set /a plugin_counter+=1

set download_index[!plugin_counter!]=mcore
set desired_name[!plugin_counter!]=MassiveCore
set download_location[!plugin_counter!]=bukget
set /a plugin_counter+=1

set download_index[!plugin_counter!]=mcmmo
set desired_name[!plugin_counter!]=mcMMO
set download_location[!plugin_counter!]=bukget
set /a plugin_counter+=1

set download_index[!plugin_counter!]=modifyworld
set desired_name[!plugin_counter!]=ModifyWorld
set download_location[!plugin_counter!]=bukget
set /a plugin_counter+=1

set download_index[!plugin_counter!]=multiverse-core
set desired_name[!plugin_counter!]=MultiverseCore
set download_location[!plugin_counter!]=bukget
set /a plugin_counter+=1

set download_index[!plugin_counter!]=multiverse-inventories
set desired_name[!plugin_counter!]=MultiverseInventories
set download_location[!plugin_counter!]=bukget
set /a plugin_counter+=1

set download_index[!plugin_counter!]=multiverse-netherportals
set desired_name[!plugin_counter!]=MultiverseNetherPortals
set download_location[!plugin_counter!]=bukget
set /a plugin_counter+=1

set download_index[!plugin_counter!]=multiverse-portals
set desired_name[!plugin_counter!]=MultiversePortals
set download_location[!plugin_counter!]=bukget
set /a plugin_counter+=1

set download_index[!plugin_counter!]=multiverse-teleportfilter
set desired_name[!plugin_counter!]=MultiverseTeleportFilder
set download_location[!plugin_counter!]=bukget
set /a plugin_counter+=1

set download_index[!plugin_counter!]=nobreeding
set desired_name[!plugin_counter!]=NoBreeding
set download_location[!plugin_counter!]=bukget
set plugin_disabled_reason[!plugin_counter!]=Inactive project; no updates.
set /a plugin_counter+=1

set download_index[!plugin_counter!]=nocheatplus
set desired_name[!plugin_counter!]=NoCheatPlus
set download_location[!plugin_counter!]=jenkins
set /a plugin_counter+=1

set download_index[!plugin_counter!]=ontime
set desired_name[!plugin_counter!]=OnTime
set download_location[!plugin_counter!]=bukget
set /a plugin_counter+=1

set download_index[!plugin_counter!]=openinv
set desired_name[!plugin_counter!]=OpenInv
set download_location[!plugin_counter!]=bukget
set /a plugin_counter+=1

set download_index[!plugin_counter!]=permissionsex
set desired_name[!plugin_counter!]=PermissionsEx
set download_location[!plugin_counter!]=bukget
set /a plugin_counter+=1

set download_index[!plugin_counter!]=perworldplugins
set desired_name[!plugin_counter!]=PerWorldPlugins
set download_location[!plugin_counter!]=bukget
set /a plugin_counter+=1

set download_index[!plugin_counter!]=plotme
set desired_name[!plugin_counter!]=PlotMe
set download_location[!plugin_counter!]=bukget
set /a plugin_counter+=1

set download_index[!plugin_counter!]=plotme-defaultgenerator
set desired_name[!plugin_counter!]=PlotMeDefaultGenerator
set download_location[!plugin_counter!]=bukget
set /a plugin_counter+=1

set download_index[!plugin_counter!]=protocollib
set desired_name[!plugin_counter!]=ProtocolLib
set download_location[!plugin_counter!]=jenkins
set /a plugin_counter+=1

set download_index[!plugin_counter!]=ptweaks-remove-all-server-lag
set desired_name[!plugin_counter!]=pTweaks
set download_location[!plugin_counter!]=bukget
set /a plugin_counter+=1

set download_index[!plugin_counter!]=pvpmanager
set desired_name[!plugin_counter!]=PvP-Manager
set download_location[!plugin_counter!]=bukget
set /a plugin_counter+=1

set download_index[!plugin_counter!]=pwnplantgrowth
set desired_name[!plugin_counter!]=pwnPlantGrowth
set download_location[!plugin_counter!]=bukget
set /a plugin_counter+=1

set download_index[!plugin_counter!]=signedit
set desired_name[!plugin_counter!]=SignEdit
set download_location[!plugin_counter!]=bukget
set /a plugin_counter+=1

set download_index[!plugin_counter!]=simplesort
set desired_name[!plugin_counter!]=SimpleSort
set download_location[!plugin_counter!]=bukget
set /a plugin_counter+=1

set download_index[!plugin_counter!]=tjp
set desired_name[!plugin_counter!]=TheJoyOfPainting
set download_location[!plugin_counter!]=bukget
set /a plugin_counter+=1

set download_index[!plugin_counter!]=toolswap
set desired_name[!plugin_counter!]=ToolSwap
set download_location[!plugin_counter!]=bukget
set /a plugin_counter+=1

set download_index[!plugin_counter!]=treeassist
set desired_name[!plugin_counter!]=TreeAssist
set download_location[!plugin_counter!]=bukget
set /a plugin_counter+=1

set download_index[!plugin_counter!]=vault
set desired_name[!plugin_counter!]=Vault
set download_location[!plugin_counter!]=bukget
set /a plugin_counter+=1

set download_index[!plugin_counter!]=voxelsniper
set desired_name[!plugin_counter!]=VoxelSniper
set download_location[!plugin_counter!]=bukget
set /a plugin_counter+=1

set download_index[!plugin_counter!]=whatisit
set desired_name[!plugin_counter!]=WhatIsIt
set download_location[!plugin_counter!]=bukget
set /a plugin_counter+=1

set download_index[!plugin_counter!]=worldedit
set desired_name[!plugin_counter!]=WorldEdit
set download_location[!plugin_counter!]=bukget
set /a plugin_counter+=1

set download_index[!plugin_counter!]=worldguard
set desired_name[!plugin_counter!]=WorldGuard
set download_location[!plugin_counter!]=bukget

echo ---- Beginning downloads ----
echo.

rem for every plugin with var %%p being the number of the plugin
rem for all *_c variables, the c stands for current
rem %%p, p for plugin!
for /l %%p in (1,1,!plugin_counter!) do (

    if defined zip_location[%%p] (
        set file_name_c=!desired_name[%%p]!.zip
        set file_type_c=zip
    ) else (
        set file_name_c=!desired_name[%%p]!.jar
        set file_type_c=jar
    )

    rem Try downloading 3 times.
    for /l %%n in (1,1,3) do (
        rem If the file has not been downloaded.
        if not exist "%output%\!file_name_c!" (

            rem If it's the first try, the download didn't fail -- it's just the first try.
            if %%n==1 (
                echo Downloading !desired_name[%%p]!
                echo Downloading !file_name_c!>>%log%
            rem If it's the second try or later, the download failed and we are retrying
            ) else (
                echo Download failed. Retrying...
                echo Download failed. Retrying...>>%log%
            )

            if !download_location[%%p]!==bukget (
                cscript //nologo %dl_vbs% "https://api.bukget.org/3/plugins/bukkit/!download_index[%%p]!/%type%/download" "%output%\!file_name_c!"
            )
            if !download_location[%%p]!==jenkins (
                cscript //nologo %dl_vbs% "http://ci.md-5.net/job/!download_index[%%p]!/lastSuccessfulBuild/artifact/target/!file_name_c!" "%output%\!file_name_c!"
            ) else (
                cscript //nologo %dl_vbs% "!download_location[%%p]!" "%output%\!file_name_c!"
            )
        )
    )

    rem If the file STILL doesn't exist, the download failed.
    if not exist "%output%\!file_name_c!" (
        echo Could not download.
        echo Could not download.>>%log%

    rem If it didn't fail, continue.
    ) else (
        rem If it's a zip file, we need to unzip it.
        if defined zip_location[%%p] (
            rem Try unzipping 3 times.
            for %%n in (1,1,3) do (
                rem If it's the first try, the unzip attempt didn't fail -- it's just the first try.
                if %%n==1 (
                    echo Unzipping !desired_name[%%p]!
                    echo Unzipping !file_name_c!>>%log%
                rem If it's the second try or later, the unzip attempt failed and we are retrying
                ) else (
                    echo Unzipping failed. Retrying...
                    echo Unzip attempt failed. Retrying...>>%log%
                )
                rem If we have not successfully unzipped
                if not exist "%output%\!desired_name[%%p]!.jar" (
                    rem Make a temporary folder to unzip to.
                    md %zip_temp%

                    rem Unzip the plugin to the temporary folder
                    cscript //nologo %zip_vbs% "%cd%\%zip_temp%\" "%cd%\%output%\!file_name_c!"

                    rem Move the file we need to another folder (we need this for files we don't know the names of)
                    md "%zip_temp%\final"
                    move "%zip_temp%\!zip_location[%%p]!" "%zip_temp%\final\"

                    rem Rename file to the desired name
                    ren "%zip_temp%\final\*.jar" "!desired_name[%%p]!.jar"

                    rem Move the file to the output directory
                    move "%zip_temp%\final\!desired_name[%%p]!.jar" "%output%\"

                    rem Delete the temporary folder
                    rd /s /q %zip_temp%

                    rem Delete the original zip file
                    del /q "%output%\!file_name_c!"
                )
            )
        )    
    )
    echo.
    echo.>>%log%
)

rem If getting "Access denied" when trying to run this batch, see here -- the internet-security-options-related answer: https://stackoverflow.com/questions/17401413/msxml3-dll-access-denied

endlocal

使用批处理文件可以得到预期的输出,但 VBS 会出错(larger image):

文件按预期下载,所以我有两个问题:

  • 这个错误是个问题吗?
  • 我该如何解决?

这有点令人困惑,因为这个错误从未出现在 the other batch file I use for this 上,旨在执行完全相同的操作。

注意:如果我尝试使用 dim xHttp: Set xHttp = createobject("Microsoft.XMLHTTP.6.0"),我会收到此 VBS 错误:dl.vbs(6, 12) Microsoft VBScript 运行时错误:ActiveX 组件无法创建对象:'Microsoft.XMLHTTP.6.0'

另一个注意事项:知道如何编写 VBS 代码。因此,我不会理解技术细节。请尽量让您的答案简单明了,并记住我是在寻找答案,而不是解释——只是因为我不理解它们。

感谢您的帮助:]

最佳答案

原来这个错误意味着我正在尝试使用无效的 URL 下载。

但下载有效。

重点是:我有 3 类下载:

  • 来自 x 服务,
  • 来自 y 服务,
  • 来自定制服务。

而不是使用:

If (want x service):
    downloadFrom.service(x)
Elif (want y service):
    downloadFrom.service(y)
Else
    downloadFrom.service(custom)

我一直在使用:

If (want x service):
    downloadFrom.service(x)
If (want y service):
    downloadFrom.service(y)
Else
    downloadFrom.service(custom)

意思是如果 If (want x service)=true,它将同时从服务 x 和自定义服务下载。

感谢@SomethingDark 带领我找到了这个解决方案!

关于windows - 下载VBS错误 "(null): 0x80072EE6",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31106583/

有关windows - 下载VBS错误 "(null): 0x80072EE6"的更多相关文章

  1. ruby - 在 Ruby 程序执行时阻止 Windows 7 PC 进入休眠状态 - 2

    我需要在客户计算机上运行Ruby应用程序。通常需要几天才能完成(复制大备份文件)。问题是如果启用sleep,它会中断应用程序。否则,计算机将持续运行数周,直到我下次访问为止。有什么方法可以防止执行期间休眠并让Windows在执行后休眠吗?欢迎任何疯狂的想法;-) 最佳答案 Here建议使用SetThreadExecutionStateWinAPI函数,使应用程序能够通知系统它正在使用中,从而防止系统在应用程序运行时进入休眠状态或关闭显示。像这样的东西:require'Win32API'ES_AWAYMODE_REQUIRED=0x0

  2. ruby-on-rails - rails : "missing partial" when calling 'render' in RSpec test - 2

    我正在尝试测试是否存在表单。我是Rails新手。我的new.html.erb_spec.rb文件的内容是:require'spec_helper'describe"messages/new.html.erb"doit"shouldrendertheform"dorender'/messages/new.html.erb'reponse.shouldhave_form_putting_to(@message)with_submit_buttonendendView本身,new.html.erb,有代码:当我运行rspec时,它失败了:1)messages/new.html.erbshou

  3. ruby-on-rails - 由于 "wkhtmltopdf",PDFKIT 显然无法正常工作 - 2

    我在从html页面生成PDF时遇到问题。我正在使用PDFkit。在安装它的过程中,我注意到我需要wkhtmltopdf。所以我也安装了它。我做了PDFkit的文档所说的一切......现在我在尝试加载PDF时遇到了这个错误。这里是错误:commandfailed:"/usr/local/bin/wkhtmltopdf""--margin-right""0.75in""--page-size""Letter""--margin-top""0.75in""--margin-bottom""0.75in""--encoding""UTF-8""--margin-left""0.75in""-

  4. ruby - 检查 "command"的输出应该包含 NilClass 的意外崩溃 - 2

    为了将Cucumber用于命令行脚本,我按照提供的说明安装了arubagem。它在我的Gemfile中,我可以验证是否安装了正确的版本并且我已经包含了require'aruba/cucumber'在'features/env.rb'中为了确保它能正常工作,我写了以下场景:@announceScenario:Testingcucumber/arubaGivenablankslateThentheoutputfrom"ls-la"shouldcontain"drw"假设事情应该失败。它确实失败了,但失败的原因是错误的:@announceScenario:Testingcucumber/ar

  5. ruby - 如何使用 Ruby aws/s3 Gem 生成安全 URL 以从 s3 下载文件 - 2

    我正在编写一个小脚本来定位aws存储桶中的特定文件,并创建一个临时验证的url以发送给同事。(理想情况下,这将创建类似于在控制台上右键单击存储桶中的文件并复制链接地址的结果)。我研究过回形针,它似乎不符合这个标准,但我可能只是不知道它的全部功能。我尝试了以下方法:defauthenticated_url(file_name,bucket)AWS::S3::S3Object.url_for(file_name,bucket,:secure=>true,:expires=>20*60)end产生这种类型的结果:...-1.amazonaws.com/file_path/file.zip.A

  6. ruby-on-rails - 迷你测试错误 : "NameError: uninitialized constant" - 2

    我遵循MichaelHartl的“RubyonRails教程:学习Web开发”,并创建了检查用户名和电子邮件长度有效性的测试(名称最多50个字符,电子邮件最多255个字符)。test/helpers/application_helper_test.rb的内容是:require'test_helper'classApplicationHelperTest在运行bundleexecraketest时,所有测试都通过了,但我看到以下消息在最后被标记为错误:ERROR["test_full_title_helper",ApplicationHelperTest,1.820016791]test

  7. ruby-on-rails - 相关表上的范围为 "WHERE ... LIKE" - 2

    我正在尝试从Postgresql表(table1)中获取数据,该表由另一个相关表(property)的字段(table2)过滤。在纯SQL中,我会这样编写查询:SELECT*FROMtable1JOINtable2USING(table2_id)WHEREtable2.propertyLIKE'query%'这工作正常:scope:my_scope,->(query){includes(:table2).where("table2.property":query)}但我真正需要的是使用LIKE运算符进行过滤,而不是严格相等。然而,这是行不通的:scope:my_scope,->(que

  8. 使用 ACL 调用 upload_file 时出现 Ruby S3 "Access Denied"错误 - 2

    我正在尝试编写一个将文件上传到AWS并公开该文件的Ruby脚本。我做了以下事情:s3=Aws::S3::Resource.new(credentials:Aws::Credentials.new(KEY,SECRET),region:'us-west-2')obj=s3.bucket('stg-db').object('key')obj.upload_file(filename)这似乎工作正常,除了该文件不是公开可用的,而且我无法获得它的公共(public)URL。但是当我登录到S3时,我可以正常查看我的文件。为了使其公开可用,我将最后一行更改为obj.upload_file(file

  9. ruby - 安装 Ruby 时遇到问题(无法下载资源 "readline--patch") - 2

    当我尝试安装Ruby时遇到此错误。我试过查看this和this但无济于事➜~brewinstallrubyWarning:YouareusingOSX10.12.Wedonotprovidesupportforthispre-releaseversion.Youmayencounterbuildfailuresorotherbreakages.Pleasecreatepull-requestsinsteadoffilingissues.==>Installingdependenciesforruby:readline,libyaml,makedepend==>Installingrub

  10. ruby - 在 Windows 机器上使用 Ruby 进行开发是否会适得其反? - 2

    这似乎非常适得其反,因为太多的gem会在window上破裂。我一直在处理很多mysql和ruby​​-mysqlgem问题(gem本身发生段错误,一个名为UnixSocket的类显然在Windows机器上不能正常工作,等等)。我只是在浪费时间吗?我应该转向不同的脚本语言吗? 最佳答案 我在Windows上使用Ruby的经验很少,但是当我开始使用Ruby时,我是在Windows上,我的总体印象是它不是Windows原生系统。因此,在主要使用Windows多年之后,开始使用Ruby促使我切换回原来的系统Unix,这次是Linux。Rub

随机推荐