ur

Unable to detect zip file

13 posts in this topic

I got a UDF to zip the files from below link.

With this I am able to create a zip file but the post processing of zip file creation I am checking the zip file exists or not, but it is giving the message as file not found.

 

Any sugestions??

#include "Zip.au3"

ZipLogs()

Func ZipLogs()
    $ResultsFolder = @ScriptDir & "\Results"
    $ResultsDestFolder = @ScriptDir & "\Results_Archive"
    $zipFile = $ResultsDestFolder & "\Results_"&TodayDateTime()&".zip"

    DirCreate($ResultsDestFolder)

    Dim $Zip = _Zip_Create($zipFile) ;Create The Zip File. Returns a Handle to the zip File
    _Zip_AddFolderContents($Zip, $ResultsFolder) ;Add a folder's content in the zip file

    if FileExists(@ScriptDir&"\Logging.log") then
        _Zip_AddFile($Zip,@ScriptDir&"\Logging.log")
        FileDelete(@ScriptDir&"\Logging.log")
    EndIf

    if FileExists(@ScriptDir&"\RemoteExecution_Log.txt") then
        _Zip_AddFile($Zip,@ScriptDir&"\RemoteExecution_Log.txt")
        FileDelete(@ScriptDir&"\RemoteExecution_Log.txt")
    EndIf

    if FileExists($zipFile) then
        DirRemove($ResultsFolder,$DIR_REMOVE)
    Else
        MsgBox(0,"","Zip file not found")
    EndIf

    return $zipFile
EndFunc

 

Zip.au3

Share this post


Link to post
Share on other sites



The _ZIP* functions set macro @error when there was a problem. So you should check this macro after having called a _ZIP* function.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

@water

Sorry the info is not correct earlier,

the file is able to detect with file exists.

But when I pass that file name to the below code.

Dim $zip_file = ZipLogs()

if FileExists($zip_file) then
    MsgBox(0,"",$zip_file)
    SendAutoMail("AutoIT:Install Testing Process","Testing of Installers completed","PFA: attached log files",$zip_file)
Else
    SendAutoMail("AutoIT:Install Testing Process","Testing of Installers completed","Log files not found to attach")
EndIf

It is able to go the first branch of code as I am able to get the message prompt.

But I am not getting any email.

SendMail.au3

I am able to get the mail if I pass some other attachments for testing.

Can you suggest for this.

Share this post


Link to post
Share on other sites

What I posted above is true for SendAutoMail as well. Check @error or the return value.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
11 minutes ago, water said:

What I posted above is true for SendAutoMail as well. Check @error or the return value.

I am getting the @error value as 2.

And the 2 is at the codeblock

$objEmail.Send
    If @error Then
        SetError(2)
        Return $oMyRet[1]
    EndIf

Any idea??How to resolve this.??

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Please search the forum for _INetSmtpMailCom. IIRC this has beend discussed multiple times.

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

@water , YeahI tried many links but no resolution for this.

 

THe error I am getting at the send method.

Share this post


Link to post
Share on other sites

Add a COM error handler to your script to get more detailed error information. Easiest way is to use the Debug UDF:

#include <Debug.au3>
_DebugSetup()
_DebugCOMError()

... Your script goes here ...

 


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

When I tried to pass the zip file to the mail function after the zipping is done, it is giving return code 2.

But if I try again as a separate au3 file by sending the zip file as argument later, it is sending.

So I tried whether file is in use or not by below code but I am geting the second message stating that file is not in use.

#include "SendMail.au3"
$f = @TempDir&"\logs.zip"

$filename = $f
    if FileInUse($filename) Then
        MsgBox(0, "", "File is in use")
    Else
        MsgBox(0, "", "Not in use - go nuts")
        SendAutoMail("AutoIT:Install Testing Process","Testing of Installers completed","PFA: attached log files",$f)
    EndIf

;SendAutoMail("AutoIT:Install Testing Process","Got the Installers","Will intimate once the process is completed",$f)
;SendAutoMail("AutoIT:Install Testing Process","Testing of Installers completed","PFA: attached log files",$f)

Func FileInUse($filename)
    $handle = FileOpen($filename, 1)

    $result = False
    if $handle = -1 then $result = True

    FileClose($handle)

    return $result
EndFunc

Any idea??

Share this post


Link to post
Share on other sites

#10 ·  Posted

@water , YeahI tried many links but no resolution for this.

 

I am getting below error while sending mail..

---------------------------
sendmail error: 2
---------------------------
The message could not be sent to the SMTP server. The transport error code was 0x80040217. The server response was not available
---------------------------
OK  
---------------------------
 

I have already enabled less secure app setting in gmail.

Share this post


Link to post
Share on other sites

#11 ·  Posted

Searching the web for "SMTP transport error code 0x80040217" returns a lot of hits.
One names a wrong username/password as the culprit.
http://stackoverflow.com/questions/9157087/getting-error-transport-error-code-was-0x80040217-while-sending-email-in-asp-net


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#12 ·  Posted

But I am able to send mails at the start of the program...Once I process everything at the end  am getting this error for sending mail at process completion.

Share this post


Link to post
Share on other sites

#13 ·  Posted

Can you verify that all variables still have the correct value before sending?
I once re-used a variable for something different and hence a function call crashed.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

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

  • Similar Content

    • ur
      By ur
      There is a build machine in the network where it will automatically download the code from source repository and compile using visual studio and compresses the complete code in a zip file.
      I have added a line at the end of the build script(written in python on that machine) to copy that zip file to my ESX Virtual machine.
      Where I kept a AutoIT exe to wait for the zip file, once it is copied then I will extract the contents and find only the dll files in the extracted folder and do the Install creation using Installshield silently and copy the created setup files to anther machine.
      I wrote the script till the setup files creation.
       
      But now the problem is, when the zip file is copying through network, the autoit script is detecting it even the copy is still in progress and trying to extract the zip file and failing.
      Even when I am checking whether the file in use is not working.
       
      Any suggestion on how to check whether the copy is completed.?
    • Comboku
      By Comboku
      Hi guys,
      i hope i am in the right place for this question as it is in regards to zip.au3.
      I have some encrypted files on my harddrive which zip.au3 can't open. This is perfectly fine. The Problem is that it crashes my program as soon as it tries to access the file.
      Is there a way to detect if the file is encrypted BEFORE autoit tries to open it? I am using _zip_unzipall to unzip the file, i also tried _zip_count with the same result. My files are encrypted with SafeGuard Lan Crypt. 
       
      Thanks,
      Comboku
       
    • j0kky
      By j0kky
      Hi guys,
      I often need zipping\unzipping function within my scripts, so I've decided to do a systematic research about it to understand which options I had. I'm sharing with you these results because I think it can save some time to somobody
      Autoit coders produced much material from 2005 till now, most of it consists of UDF wrappers of 3rd parts libraries, but there are some exception.
      Let's start:
      ZIP from scratch UDF: written by joakim. You can retrieve some info from a zip file, but it is just a PoC script, as I can see. LZ UDF: written by trancexx: another exception. It use native windows compression, so it doesn't need anything. It can work with memory, it doesn't work with files. LZMA UDF: written by Ward. He writes a dll which can be directly included or can be embedded within an au3 file. It can work with memory, it doesn't work with files. [it needs LZMA.dll or LZMA.dll.au3](link missing) Package UDF: written by Yashied. It is useful for dealing with package (.pkr) file. ZIP UDF: written by Wraithdu (yet torels UDF): the exception! Based on zipfldr.dll, a native library of Windows, so it does not need to include an external library into the script. It is its strenght, but its weak point too: if zipfldr.dll is corrupted or is missing, your script will not do what you expect. gZip UDF: written by Zinthose. Based on the parsing of gZip.exe output. It can work with memory, it doesn't work with files. [it needs gZip.exe] ZLib UDF: written by monoceres. Based on ZLib.dll. It can compress\uncompress data in memory, it doesn't work with files. [it needs ZLib.dll] pZip UDF: written by asdf8. Based on ZLib.dll. It can extract\add\overwrite file into archives. [it needs pZip.dll] ZLib and gZip UDF: written by Ward. Based on ZLib.dll but it does not need the dll file, because it is written directly in the UDF! It can compress\uncompress data in memory, and it can work with files. It works with gZip format too. (link missing) XZip UDF: written by eltorro, KXM and erifash. Based on XZip.dll, a COM dll. [it needs XZip.dll] XZip UDF: written by mLipok. Based on XZip.dll, a COM dll. A more complete alternative to previous UDF. [it needs XZip.dll] unRAR UDF: written by rasim. Based on unRAR.dll. You can just uncompress rar files with this one (the only method for new v5 RAR files). [it needs unRAR.dll] Parsing unRAR.exe output: you can just uncompress rar files in this way (the only method for new v5 RAR files). [it needs unRAR.exe] 7Zip: I spent a lot of time with it, because I think it is the most useful, there are different approaches: Parsing 7za.exe output, it is the simplest (and in my opinion the best) way, some UDFs can help with it, as jennico UDF (thanks to Screen Scrape script by Valik, it seems it doesn't work in Windows 10) [it needs 7za.exe] Using 3rd part dll, as rasim UDF (yet jak UDF). He rewrites a dll which can be simply invoked by his UDF [it needs 7-zip32.dll and\or 7-zip64.dll]. With Decipher UDF you doesn't need to include the dll in your project, because it is compiled into the script and loaded in memory directly at runtime. Invoking 7za.dll. This is the most complicated approach because the library doesn't use standard COM interfaces. Anyway dany, Starg, milky, trancexx, Mugen and finally Biatu had spent some time with it and they reach a sort of partial result. [it needs 7za.dll]  
      Comment here to add suggestions\links\UDF I forgot and I'll update this post with them!
    • topten
      By topten
      Very simple: I had seen many examples of unzipping files (Zip) archive, but most of those example where using either some external .dll or are performing the job with the progress bar. Here is a small example how you can unzip your files without any external libraries and without any progress bar
      $ZipFile5="C:\file.zip" $ExtractTo5="C:\folder" $objShell5 = ObjCreate ("Shell.Application") $FilesInZip5=$objShell5.NameSpace($ZipFile5).items $objShell5.NameSpace($ExtractTo5).CopyHere($FilesInZip5,0x4) Enjoy
    • souldjer777
      By souldjer777
      Good Morning AutoIT Gurus! First - props to AutoIT and props to you guys  It's an incredibly rich featured programming language - Thank you, thank you, thank you!   Source:Gray Scripter - Zip32 '?do=embed' frameborder='0' data-embedContent>>   Here is my issue with using the <Zip32.au3> If my folder name has periods in it, the zip function fails:   Script Portion: $FolderName01 = "Computer_IP_192.168.2.1" ; Example formatting: ; _ZIP_Archive($ZipFile, $DirToZip) _ZIP_Archive($FolderName01, @ScriptDir & '' & $FolderName01)   Console Output: !> _ZIPPrint: zip I/O error !> _ZIPPrint: zip error: Could not create output file (Computer_IP_192.168.2.1)   Basically this Zip32.au3 can't zip folders with periods in them. Is this something discovered already?   This is my current work around: $FolderName01 = StringRegExpReplace( $FolderName01, "[.]", "_")   Just wondering if there is an update because I love the function Zip32.au3! "I put that sh** on everything" like Frank's Redhot    Thanks!