Download VBS error "(null): 0x80072EE6"

2

I have this VBS for downloading files:

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

and this batch file (pastebin), which is supposed to download a bunch of files and unzip the zipped ones:

@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

And using the batch file gives output as expected, with an error from the VBS (larger image):

Output

The files download as expected, so I have two questions:

  • Is this error a problem?
  • How can I fix it?

It's a little confusing since this error never appears on the other batch file I use for this, which is designed to do the exact same thing.

A note: If I try to use dim xHttp: Set xHttp = createobject("Microsoft.XMLHTTP.6.0"), I get this VBS error: dl.vbs(6, 12) Microsoft VBScript runtime error: ActiveX component can't create object: 'Microsoft.XMLHTTP.6.0'

Another note: I do not know how to code VBS's. As such, I won't understand technicalities. Please try to keep your answers simple, and keep in mind I am looking for answers, not explanations -- just because I wouldn't understand them.

Thanks for any help :]

windows
batch-file
vbscript
asked on Stack Overflow Jun 29, 2015 by Quelklef • edited Jun 29, 2015 by SomethingDark

1 Answer

0

Turns out the error means I'm trying to download with an invalid URL.

But the downloads work.

Here's the catch: I had 3 categories of download:

  • From x service,
  • From y service,
  • From a custom service.

Instead of using:

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

I had been using:

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

Meaning if If (want x service)=true, it would download both from service x and from a custom service.

Thanks to @SomethingDark who lead me to find this solution!

answered on Stack Overflow Jun 29, 2015 by Quelklef

User contributions licensed under CC BY-SA 3.0