Search code examples
inno-setup

Return output filename generated by Inno Setup preprocessor to a batch script


I'm setting up a batch file that will compile my application, the compile the installer using Inno Setup.

My setup filename is determined using some ISPP command in Inno Setup (creating the filename from the build version, among other things).
The last step is to upload the setup to my FTP, but for this I need a way to retrieve the installer filename generated by Inno Setup.

Is there a way to do that?


Solution

  • You can write a preprocessor variable value to a file.

    One way is to execute an external program to do the writing using Exec function:

    #define FileName "foobar"
    
    #expr Exec( \
        "cmd.exe", "/c echo " + FileName + "> """ + SourcePath + "\filename.txt""", , , \
        SW_HIDE)
    

    You can then read the file in your batch file. Or you can have the preprocessor generate a full FTP upload script and just execute it from the batch file.


    Another way is to create an INI file using WriteIni function:

    #define FileName "foobar"
    
    #expr WriteIni(SourcePath  + "\filename.ini", "Section", "FileName", FileName)
    

    Though personally, I'd generate the file name in the batch file (or replace the batch file with a better language), and pass it to Inno Setup, rather then the other way around.