allSystemsGo Posted February 13, 2013 Posted February 13, 2013 So I am writing a script that will download a file off of the internet, and then install it. However, it is a zip file, so it needs to be unzipped. I downloaded the _Zip.au3 UDF from the wiki, but the _Zip_UnzipAll function does not appear to be working. Here is my code... #include <_Zip.au3> Local $hDownload= InetGet("www.url.com/file.zip", "file.zip" , 1) Do Sleep(250) Until InetGetInfo($hDownload,2) Local $nBytes= InetGetInfo($hDownload,0) InetClose($hDownload) Sleep(1000) $sZipFile= "C:\file.zip" $iDestPath="C:\folder" _zip_Unzipall($sZipFile,$iDestPath) code edited for general security reasons..
Kyan Posted February 13, 2013 Posted February 13, 2013 (edited) Check if this works #include <Zip.au3> $sZipFile = @ScriptDir & "\file.zip" $iDestPath = @DesktopDir & "\Unziped" ; if folder does not exists _zip udf creates onde Local $hDownload = InetGet("www.url.com/file.zip", @ScriptDir & "\file.zip", 1) Do Sleep(250) Until InetGetInfo($hDownload, 2) Local $nBytes = InetGetInfo($hDownload, 0) InetClose($hDownload) ConsoleWrite("Download completed" & @CRLF) Sleep(1000) ConsoleWrite("Unzip started..." & @CRLF) $flag = _zip_Unzipall($sZipFile, $iDestPath,1) ConsoleWrite("Unzip finished..." & @CRLF) If @error Then Switch @error Case 1 ConsoleWrite("ERROR: No zip file" & @LF) Case 2 ConsoleWrite("ERROR: No dll" & @LF) Case 3 ConsoleWrite("ERRO: dll isn't registered" & @LF) EndSwitch EndIf If $flag Then ConsoleWrite($sZipFile & " Was sucessefuly extracted" & @LF) By some reason at udf description it says when $flag is set to 0, it extracted all files with success, but it is setting to 1, so i updated the code Edited February 13, 2013 by DiOgO Heroes, there is no such thing One day I'll discover what IE.au3 has of special for so many users using it.C'mon there's InetRead and WinHTTP, way better
allSystemsGo Posted February 13, 2013 Author Posted February 13, 2013 Check if this works #include <Zip.au3> $sZipFile = @ScriptDir & "\file.zip" $iDestPath = @DesktopDir & "\Unziped" ; if folder does not exists _zip udf creates onde Local $hDownload = InetGet("www.url.com/file.zip", @ScriptDir & "\file.zip", 1) Do Sleep(250) Until InetGetInfo($hDownload, 2) Local $nBytes = InetGetInfo($hDownload, 0) InetClose($hDownload) ConsoleWrite("Download completed" & @CRLF) Sleep(1000) ConsoleWrite("Unzip started..." & @CRLF) $flag = _zip_Unzipall($sZipFile, $iDestPath,1) ConsoleWrite("Unzip finished..." & @CRLF) If @error Then Switch @error Case 1 ConsoleWrite("ERROR: No zip file" & @LF) Case 2 ConsoleWrite("ERROR: No dll" & @LF) Case 3 ConsoleWrite("ERRO: dll isn't registered" & @LF) EndSwitch EndIf If $flag Then ConsoleWrite($sZipFile & " Was sucessefuly extracted" & @LF) By some reason at udf description it says when $flag is set to 0, it extracted all files with success, but it is setting to 1, so i updated the code It downloads the file...that is it. It seems to be doing something, since the script doesn't exit...it stays present in task manager.
Kyan Posted February 13, 2013 Posted February 13, 2013 It downloads the file...that is it. It seems to be doing something, since the script doesn't exit...it stays present in task manager.could you point me to the zip (or other by example) which you're trying to download? may is something to do with the server Heroes, there is no such thing One day I'll discover what IE.au3 has of special for so many users using it.C'mon there's InetRead and WinHTTP, way better
allSystemsGo Posted February 13, 2013 Author Posted February 13, 2013 could you point me to the zip (or other by example) which you're trying to download? may is something to do with the serverSurehttp://www.thinprint.com/Portals/deutsch/Software/Clients/TPCLWin3290.zip
Kyan Posted February 13, 2013 Posted February 13, 2013 Sure http://www.thinprint.com/Portals/deutsch/Software/Clients/TPCLWin3290.zip here it is expandcollapse popup#include $sZipFile = @ScriptDir & "\file.zip" $iDestPath = @DesktopDir & "\Unziped" ; if folder does not exists _zip udf creates one If FileExists($sZipFile) Then FileDelete($sZipFile) $hDownload = InetGet("http://www.thinprint.com/Portals/deutsch/Software/Clients/TPCLWin3290.zip", @ScriptDir & "\file.zip", 1,1) $stotalSize = InetGetInfo($hDownload,1) If $stotalSize = 0 Then $resp = MsgBox(36,"","The total size cannot be read, do you want continue?") If $resp = 6 Then _download(0) Else If FileExists($sZipFile) Then FileDelete($sZipFile) InetClose($hDownload) Exit EndIf Else _download(1) EndIf Func _download($progress = 0) Do If $progress Then $cur = InetGetInfo($hDownload,0) ConsoleWrite("Progress:"&Round($cur*100/$stotalSize)&"%"&@LF) Else ConsoleWrite("Downloaded so far: "&Round(FileGetSize($sZipFile)/1024,2)&"kb"&@LF) EndIf Sleep(250) Until InetGetInfo($hDownload, 2) ;$nBytes = InetGetInfo($hDownload, 0) InetClose($hDownload) ConsoleWrite("Download completed" & @CRLF) Sleep(1000) ConsoleWrite("Unzip started..." & @CRLF) $flag = _zip_Unzipall($sZipFile, $iDestPath,1) ConsoleWrite("Unzip finished..." & @CRLF) If @error Then Switch @error Case 1 ConsoleWrite("ERROR: No zip file" & @LF) Case 2 ConsoleWrite("ERROR: No dll" & @LF) Case 3 ConsoleWrite("ERRO: dll isn't registered" & @LF) EndSwitch EndIf If $flag Then ConsoleWrite($sZipFile & " Was sucessefuly extracted" & @LF) EndFunc Heroes, there is no such thing One day I'll discover what IE.au3 has of special for so many users using it.C'mon there's InetRead and WinHTTP, way better
allSystemsGo Posted February 13, 2013 Author Posted February 13, 2013 here it is expandcollapse popup#include $sZipFile = @ScriptDir & "\file.zip" $iDestPath = @DesktopDir & "\Unziped" ; if folder does not exists _zip udf creates one If FileExists($sZipFile) Then FileDelete($sZipFile) $hDownload = InetGet("http://www.thinprint.com/Portals/deutsch/Software/Clients/TPCLWin3290.zip", @ScriptDir & "\file.zip", 1,1) $stotalSize = InetGetInfo($hDownload,1) If $stotalSize = 0 Then $resp = MsgBox(36,"","The total size cannot be read, do you want continue?") If $resp = 6 Then _download(0) Else If FileExists($sZipFile) Then FileDelete($sZipFile) InetClose($hDownload) Exit EndIf Else _download(1) EndIf Func _download($progress = 0) Do If $progress Then $cur = InetGetInfo($hDownload,0) ConsoleWrite("Progress:"&Round($cur*100/$stotalSize)&"%"&@LF) Else ConsoleWrite("Downloaded so far: "&Round(FileGetSize($sZipFile)/1024,2)&"kb"&@LF) EndIf Sleep(250) Until InetGetInfo($hDownload, 2) ;$nBytes = InetGetInfo($hDownload, 0) InetClose($hDownload) ConsoleWrite("Download completed" & @CRLF) Sleep(1000) ConsoleWrite("Unzip started..." & @CRLF) $flag = _zip_Unzipall($sZipFile, $iDestPath,1) ConsoleWrite("Unzip finished..." & @CRLF) If @error Then Switch @error Case 1 ConsoleWrite("ERROR: No zip file" & @LF) Case 2 ConsoleWrite("ERROR: No dll" & @LF) Case 3 ConsoleWrite("ERRO: dll isn't registered" & @LF) EndSwitch EndIf If $flag Then ConsoleWrite($sZipFile & " Was sucessefuly extracted" & @LF) EndFunc Makes the "Unzipped" folder, but does not unzip the contents into it.
Kyan Posted February 13, 2013 Posted February 13, 2013 which udf are you using, I used zip.au3 from torels_, btw at the first line, <zip.au3> is missing Heroes, there is no such thing One day I'll discover what IE.au3 has of special for so many users using it.C'mon there's InetRead and WinHTTP, way better
allSystemsGo Posted February 13, 2013 Author Posted February 13, 2013 (edited) which udf are you using, I used zip.au3 from torels_, btw at the first line, <zip.au3> is missingThe one I am using is _Zip.AU3 by wraithdu...found here: I noticed that it was missing..I added it and still no success.Edit.Could you post the udf that you use so I could try with that?edit 2...Nevermind, I found it. And it works! Edited February 13, 2013 by zsutton92
Kyan Posted February 13, 2013 Posted February 13, 2013 The one I am using is _Zip.AU3 by wraithdu...found here: I noticed that it was missing..I added it and still no success.Edit.Could you post the udf that you use so I could try with that?here Heroes, there is no such thing One day I'll discover what IE.au3 has of special for so many users using it.C'mon there's InetRead and WinHTTP, way better
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