Archive: Create installer version at runtime


Create installer version at runtime
Greetings everyone,

I would like to set my installer's version information at compile time based on the version number of another executable. GetDllVersionLocal unfortunately can only be called inside a function at runtime. I would like to do this without creating a seperate script to invoke the main one. Is this possible? Thank you.

--
Kip


You need to compile this:

OutFile "GetVersion.exe"

!define File "C:\MyFile.exe"

Function .onInit
GetDllVersion "${File}" $R0 $R1
IntOp $R2 $R0 / 0x00010000
IntOp $R3 $R0 & 0x0000FFFF
IntOp $R4 $R1 / 0x00010000
IntOp $R5 $R1 & 0x0000FFFF
StrCpy $R1 "$R2.$R3.$R4.$R5"

FileOpen $R0 "$EXEDIR\Version.txt" w
FileWrite $R0 '!echo "${File} version: $R1"$\r$\n!define Version "$R1"'
FileClose $R0
Abort
FunctionEnd

Section
SectionEnd

Make sure you change the path of C:\MyFile.exe to your EXE's path.
Put the output installer in the same place as your script, then put this at the top of your script:
!system "GetVersion.exe"
!include "Version.txt"


You will then have the ${Version} define available.

-Stu

There is another solution I came to...