Sign in to follow this  
Followers 0
allSystemsGo

Using the _Zip.AU3 UDF, File does not unzip.

10 posts in this topic

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..

Share this post


Link to post
Share on other sites



#2 ·  Posted (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 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
happy.png

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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
happy.png

Share this post


Link to post
Share on other sites

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

Sure

http://www.thinprint.com/Portals/deutsch/Software/Clients/TPCLWin3290.zip

Share this post


Link to post
Share on other sites

here it is

#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
happy.png

Share this post


Link to post
Share on other sites

here it is

#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.

Share this post


Link to post
Share on other sites

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
happy.png

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

which udf are you using, I used zip.au3 from torels_, btw at the first line, <zip.au3> is missing

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?

edit 2...

Nevermind, I found it. And it works!

Edited by zsutton92

Share this post


Link to post
Share on other sites

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
happy.png

Share this post


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
Sign in to follow this  
Followers 0