batch-fileautoit

Compiling an AutoIt script via cmd is not working with #include


#include <Constants.au3> throws an error. It works without. Using AutoIt it compiles without error. "Constants.au3" is in "G:\Program Files (x86)\AutoIt3\Include".

@echo off
    setlocal enableextensions disabledelayedexpansion
    for %%a in ("%cd%\*.au3") do (
        Aut2exe.exe /in "%%~fa" /out "%%~dpna.exe" /icon "%%~dpa\icon.ico" /x86 /comp 4
    )
    endlocal
xcopy *.exe Compile\*.exe
del /f *.exe
xcopy /D /I /V /Y Compile\Aut2exe.exe
del /f Compile\Aut2exe.exe

Solution

  • From AutoIt's documentation:

    The search order used by AutoIt depends on which form of #include you use. The tables below show the order directories are searched using both forms.

    Using #include <>

    Standard library - The path of the currently running interpreter with "\Include" appended is searched.

    User-defined libraries - The registry value mentioned above is read and each directory is searched in the order they appear in.

    Script directory - The directory of the currently executing script.

    Aut2Exe uses the same algorithm as AutoIt3.exe with the only difference being it looks for the Include sub-directory as being in a sibling directory to itself (..\Include)

    It seems you have copied aut2exe to the script's folder, but the file you are referencing is in the standard libraries folder and according to documentation it will not be found. You can: