Jump to content

InetGet - Failing To Successfully Download Programs (But has no errors?)


Recommended Posts

I'm trying to create an auto-downloader for the latest Malwarebytes from their official website. However, every time I try it fails to download the entire file and trying to run it will show:

InstallMalwarebytes-Failed-Download.png.433def52b39e21f3904337c66ab5919e.png

 

Here was my code:

#RequireAdmin

; Call a function and pass arguments:
Call("DownloadFromLink", "https://www.malwarebytes.com/mwb-download/thankyou/", "MBSetup.exe", 1, 1)

Func DownloadFromLink($sUrl, $sFilename, $i1, $i2)
    ; Try to download from the URL & store the return handler in $hDownload.
    Local $hDownload = InetGet($sUrl, $sFilename, $i1, $i2)
    
EndFunc ;===>DownloadFromLink

 

I then tried copy/pasting someone else's code temporarily for debugging purposes to determine if there were errors when it was being downloaded:

#include <InetConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>

#RequireAdmin

; Call a function and pass arguments:
Call("DownloadFromLink", "https://www.malwarebytes.com/mwb-download/thankyou/", "MBSetup.exe", 1, 1)

Func DownloadFromLink($sUrl, $sFilename, $i1, $i2)
    ; Try to download from the URL & store the return handler in $hDownload.
    Local $hDownload = InetGet($sUrl, $sFilename, $i1, $i2)

    ; >>>>>>>>>>>>> NOT MY CODE FROM HERE & LOWER <<<<<<<<<<<<<<<<<<<<<
    ; Determine whether there were errors with the download:
    Do
        Sleep(250)
    Until InetGetInfo($hDownload, $INET_DOWNLOADCOMPLETE)

    ; Retrieve details about the download file.
    Local $aData = InetGetInfo($hDownload)
    MsgBox($MB_SYSTEMMODAL, "", "Bytes read: " & $aData[$INET_DOWNLOADREAD] & @CRLF & _
                "Size: " & $aData[$INET_DOWNLOADSIZE] & @CRLF & _
                "Complete: " & $aData[$INET_DOWNLOADCOMPLETE] & @CRLF & _
                "successful: " & $aData[$INET_DOWNLOADSUCCESS] & @CRLF & _
                "@error: " & $aData[$INET_DOWNLOADERROR] & @CRLF & _
                "@extended: " & $aData[$INET_DOWNLOADEXTENDED] & @CRLF)
    Return False ; If an error occurred then return from the function

    ; Close the handle returned by InetGet.
    InetClose($hDownload)

EndFunc ;===>DownloadFromLink

Credit for Borrowed Code: https://www.autoitscript.com/autoit3/docs/functions/InetGetInfo.htm

Code Result:
(Note: The zip file is the program when I downloaded it myself manually. It is 2,000+ KB normally. The MBSetup.exe is the one the script downloaded.)

DebugInfo-DeleteLater.png.37b716fdef91e444d938079e38da57c6.png

 

What am I doing wrong? I've checked the documentation, I've tried searching it on Google, I'm at a loss.

Help would be greatly appreciated, thank you!

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...