Jump to content
ur

Unable to detect zip file

Recommended Posts

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 2020-03-26 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2020-03-21 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki, WebDriver - 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 2020-03-26 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2020-03-21 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki, WebDriver - 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

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 2020-03-26 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2020-03-21 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki, WebDriver - 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 2020-03-26 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2020-03-21 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki, WebDriver - 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

@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

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 2020-03-26 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2020-03-21 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki, WebDriver - Wiki

 

Share this post


Link to post
Share on other sites

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

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 2020-03-26 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2020-03-21 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki, WebDriver - 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

    • By Exit
      For my next project I would like to send files with "alternate data streams" by email in ZIP format.
      I can not use any external program like 7-Zip or WinRAR. (They would fit😥)
      Who knows how to create a ZIP file with "alternate data streams" included with the Powershell command "Compress-Archive"? 
      Here a test script:  (save as "ADSTester.cmd")
      @rem Try to create a zip file with alternate data streams (ADS) included @rem Housekeeping @cls @del ADSTester.zip >nul: @RD /S /Q Extracted >nul: @del ADSTester.txt >nul: @rem End of Housekeeping echo This is the ADSTester.txt file >ADSTester.txt echo This is the ADSTester.txt:Part1 file >ADSTester.txt:Part1 echo This is the ADSTester.txt:Part2 file >ADSTester.txt:Part2 dir /r ADSTester.txt @rem See the 3 files @rem **************************************************************** @rem **************************************************************** @rem Please alter the next lines to include the alternate data streams. powershell Compress-Archive -Path .\ADSTester.txt -Update -DestinationPath ADSTester.zip powershell Expand-Archive -Path ADSTester.zip -DestinationPath .\Extracted\ dir /r Extracted\ADSTester.txt @rem Only one file left :-( pause  
    • By Scriptmaster
      <NEWBIE ALERT>
      Is it possible to unzip a zip file in Autoit without using a dll!
      My script downloads a zip file to a temporary directory (successfully) and it must be unzipped to (Or moved to after unzip) another a folder which just happens to be
      @scriptdir & "file.exe" Thanks in advance
    • By Tersion
      Here the this wiki page with list of available UDFs for data compression. For my tasks I only need ZIP support, so I started looking at pure AutoIt UDFs without any 3rd party dlls. And found out that most of available realizations uses standard ("native method") Windows dll - "zipfldr.dll". So for now I chose ZIP UDF by wraithdu. I've tested it on Windows 7 (x64) and it seem works fine. But here the comment from another topic where user says that Windows 10 discontinued support of "zipfldr.dll". Now I confused. I don't have around any Windows 10 machine to tested it. So maybe someone could confirm or deny that? Or maybe would better to switch to UDF with 7zip dll?
      I need an advice...
    • By tintin92
      Hello,

      How can I automatically download a list of zip files, like the ones in the quote, using a AutoIt script?
      Is it possible with AutoIt script?
       
    • 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.?
×
×
  • Create New...