Jewtus

Trouble including a file

8 posts in this topic

I have the following line of code:

#AutoIt3Wrapper_Res_File_Add=Includes\7Zip\7-zip32.dll, rt_rcdata, 7ZIP32

This worked fine for several days but now when I try to compile, I get an error saying:

!>12:50:07 Aut2exe.exe encountered an error ended with error:   Error adding file:  7-zip32.dll .rc:2

I tried to delete the line of code just so I could compile, but even when I delete the line of code I keep getting the same error. Nothing else tries to include the dll but for some reason I cannot compile anymore. Any suggestions?

Share this post


Link to post
Share on other sites



You say nothing else tried to include the file, but logic dictates something must as you are getting that error. How about posting your entire script so we can see what you're doing?


When you're dead, you don't know you're dead - it's only difficult for those that know you. It's the same way when you're stupid...

My Scripts: SCCM UDFInclude Source with Compiled Script, Windows Firewall UDF

Share this post


Link to post
Share on other sites

This likely is a racing condition with an antivirus package.
Did you exclude the autoit3 temp directory form your AV package?
You could try the current Beta version of AutoIt3Wrapper which has some extra pause in there to (hopefully) avoid this.

Jos 


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Here is a trimmed down version of what I'm doing:

#AutoIt3Wrapper_Res_File_Add=7Zip\7-zip32.dll, rt_rcdata, 7ZIP32
#AutoIt3Wrapper_Res_File_Add=7Zip\7-zip64.dll, rt_rcdata, 7ZIP64



#include <Resources.au3>
#include <7Zip.au3> ; Found this here: https://www.autoitscript.com/forum/topic/85094-7zip/?page=7
#include <ColorConstants.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GUIListView.au3>

#cs
Inside the 7zip include I modded the paths:
Global $sNoCompiledPath = @ScriptDir & "\7Zip\" ;The directory where dll files are for non compiled use
Global $sCompiledPath = @TempDir & "\"      ;The directory where fileinstall dll files for compiled use
#ce


Unzip("C:\Users\AXRH\AppData\Local\Temp\TEST.zip")

Func Unzip($sZipFile)
    If @Compiled Then
        If @OSArch="X32" AND FileExists(@TempDir&'\7-zip32.dll')=0 Then
            _ResourceSaveToFile(@TempDir&'\7-zip32.dll',"7ZIP32")
        ElseIf @OSArch="X64" AND FileExists(@TempDir&'\7-zip64.dll')=0 Then
            _ResourceSaveToFile(@TempDir&'\7-zip64.dll',"7ZIP64")
        EndIf
    EndIf
    $loop=StringSplit($sZipFile,"\",2)
    local $sDest
    For $x=0 to UBound($loop)-2
        $sDest=$sDest&$loop[$x]&"\"
    Next
    $count=UBound($loop)-1
    $sFolder=StringSplit($loop[$count],"-",2)[0]&"\"
    $aFormattedFolder=$sDest&StringReplace($sFolder," \","\")
    $retResult = _7ZIPExtract(0, $sZipFile,$aFormattedFolder,1)
    If @error = 0 Then
        Return $aFormattedFolder
    Else
        ConsoleWrite($retResult&@CRLF)
        Return False
    EndIf
EndFunc

I think I have figured out what is going on, but I'm not sure why... I tried comment out the 7zip function that I found in example scripts and it lets me compile. I tried reverting back to the original file in the example and I still get errors. I'm not sure if I've tried to compile after the 7zip functions I added to my script but it appears to be coming from the include file.

 

EDIT: I'm certain its this section... I commented out the if not Fileinstall and it compiled... What exactly is that line for? I don't want to ditch it if it is useful.

Else ; If compiled, test and open the right dll (that must be in ScriptDir for compiling)
        If @OSArch = "X86" Then
            If Not FileInstall("7-zip32.dll", $sCompiledPath & $sZip32Dll, 1) Then Return SetError(3, 0, 0)
            $hDLL_7ZIP = DllOpen($sCompiledPath & $sZip32Dll) ; Open x32 dll from FileInstall path
        Else
            If Not FileInstall("7-zip64.dll", $sCompiledPath & $sZip64Dll, 1) Then Return SetError(3, 0, 0)
            $hDLL_7ZIP = DllOpen($sCompiledPath & $sZip64Dll) ; Open x64 dll from FileInstall path
        EndIf
    EndIf

 

Edited by Jewtus

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

As I mentioned, it is still trying to fileinstall the dll. All that is saying is FileInstall the 32bit if the OS Architecture is x86 and the 64bit if it is x64. In essence, both files are going to be included at compile time; depending on the architecture only one of them is outputted to the $sCompiledPath.

Edited by JLogan3o13

When you're dead, you don't know you're dead - it's only difficult for those that know you. It's the same way when you're stupid...

My Scripts: SCCM UDFInclude Source with Compiled Script, Windows Firewall UDF

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

@JLogan3o13 Ok, that sounds like its a better way of doing it, I still need to include these lines right:

#AutoIt3Wrapper_Res_File_Add=Includes\7Zip\7-zip32.dll, rt_rcdata, 7ZIP32
#AutoIt3Wrapper_Res_File_Add=Includes\7Zip\7-zip64.dll, rt_rcdata, 7ZIP64

and also, why would it fail to compile when the fileinstall lines aren't commented out?

Edited by Jewtus

Share this post


Link to post
Share on other sites

The answer to your first question is no: using the #AutoIt3Wrapper method and using FileInstall are two different ways to achieve the object of including a file with your compiled script, so by doing both you are actually creating double the work for yourself.

Second question: Is 7-Zip.dll in the same directory as the script? Look at FileInstall in the help file; the first parameter must be a literal path to the file being installed. It appears FileInstall cannot find the dll file in order to include it.


When you're dead, you don't know you're dead - it's only difficult for those that know you. It's the same way when you're stupid...

My Scripts: SCCM UDFInclude Source with Compiled Script, Windows Firewall UDF

Share this post


Link to post
Share on other sites

Ok that makes more sense. I'm going to keep the FileInstall commented out (the one that was in the 7zip folder did just use the file name without a path). I tried changing the path on the If not FileInstall and I got the error "Invalid FileInstall() function:".

Its working for me now so I'm going to call this solved now that I understand what's happening.

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