MuddyPiglet Posted March 19, 2021 Share Posted March 19, 2021 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: 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.) 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 comment Share on other sites More sharing options...
Danp2 Posted March 20, 2021 Share Posted March 20, 2021 Does it work if you change the URL to https://downloads.malwarebytes.com/file/mb-windows? Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
MuddyPiglet Posted March 20, 2021 Author Share Posted March 20, 2021 3 minutes ago, Danp2 said: Does it work if you change the URL to https://downloads.malwarebytes.com/file/mb-windows? Peculiar. Yes it did. Thank you very much! Link to comment Share on other sites More sharing options...
Danp2 Posted March 20, 2021 Share Posted March 20, 2021 You were downloading the HTML for that URL instead of actual file. 😄 MuddyPiglet 1 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now