GeoffCoope
21st February 2003 12:45 UTC
Using GetDLLVersion and assign to MUI_VERSION ?
Hi
I have a script that needs to get the version number from an exe file within the installation itself.
I can get the exe version of a file after it has been installed using the below code:
; Get Version of EXE file
GetDLLVersion "$INSTDIR\MyApp.exe" $R0 $R1
IntOp $R2 $R0 / 0x00010000 ; $R2 now contains major version
IntOp $R3 $R0 & 0x0000FFFF ; $R3 now contains minor version
IntOp $R4 $R1 / 0x00010000 ; $R4 now contains release
IntOp $R5 $R1 & 0x0000FFFF ; $R5 now contains build
StrCpy $0 "$R2.$R3.$R4.$R5" ; $0 now contains full version number
What I really want to do is get the version number of MyApp.EXE and assign that version number to the MUI_VERSION var at the start of the script. (I want to set the OutFile as MyApp + MUI_VERSION)
Is this possible ?
Thanks for any help
Geoff Coope
kichik
21st February 2003 13:18 UTC
Have a look at the FAQ question "How can I make my script depend on some registry value/the version of my product/<something dynamic>?". It will help you here. What you basically need to do is create another script that will compile your script with makensis /DMUI_VERSION=1.2.3.4. It will get 1.2.3.4 from the script you posted above.
GeoffCoope
21st February 2003 13:42 UTC
Great idea, I understand.
Thanks
Geoff Coope
GeoffCoope
21st February 2003 14:14 UTC
Hi Kichik
What is the minimum I need to create this installer that runs my script?
I tried this but it doesn't do anthing.
Caption "Make MyApp"
InstallDir "."
OutFile "make.exe"
Section "Go"
SetOutPath "empty"
Call GetVersion
SectionEnd
; Get Version of EXE file and send to install_data.nsi
; ----------------------------------------------------
Function GetVersion
GetDLLVersion "c:\MyApp.Exe" $R0 $R1
IntOp $R2 $R0 / 0x00010000 ; $R2 now contains major version
IntOp $R3 $R0 & 0x0000FFFF ; $R3 now contains minor version
IntOp $R4 $R1 / 0x00010000 ; $R4 now contains release
IntOp $R5 $R1 & 0x0000FFFF ; $R5 now contains build
StrCpy $0 "$R2.$R3.$R4.$R5" ; $0 now contains string like "1.2.0.192"
Exec '"C:\Program Files\NSIS\makensis.exe /DVERSION=$0 C:\Projects\MyApp\NSIS\install_data.nsi"'
FunctionEnd
Sunjammer
21st February 2003 14:39 UTC
Could be wrong, but try prefixing the "Go" name with a minus sign. Sections with a leading minus are always executed, e.g. Section -Go or Section "-Go" (not sure about whether the quotes are needed or not, and no time to test this i'm afraid)
GeoffCoope
21st February 2003 15:01 UTC
Done it,
Here it is....
This Script will get a version number (if you set one) from your EXE file and pass it to another script (your main install script) as a parameter.
1. Create a script called make.nsi
------------------------------------------------------------------
; Make.nsi
; Geoff Coope
; Gets the Version Number from an EXE file and passes it as
; a parameter $VERSION to another script.
Caption "Make"
InstallDir "."
OutFile "make.exe"
SilentInstall silent
Section "DoNothing"
SectionEnd
Function .onInit
GetDLLVersion "c:\path\afile.exe" $R0 $R1
IntOp $R2 $R0 / 0x00010000 ; $R2 now contains major version
IntOp $R3 $R0 & 0x0000FFFF ; $R3 now contains minor version
IntOp $R4 $R1 / 0x00010000 ; $R4 now contains release
IntOp $R5 $R1 & 0x0000FFFF ; $R5 now contains build
StrCpy $0 "$R2.$R3.$R4.$R5" ; $0 now contains string like "1.2.0.192"
Exec '"C:\Program Files\NSIS\makensis.exe" "/DVERSION=$0" "c:\projects\aProject\data.nsi"'
FunctionEnd
------------------------------------------------------------------
2. Compile the above script and you end up with "Make.exe"
3. Open your main install script (ive called mine data.nsi in the above example) and add the line
!define MUI_VERSION ${VERSION}
4. Run Make.exe and it will:
a) Get version number from exe in the form (x.x.x.x)
b) Calls another script passing the version number as $VERSION to it
You can now create installations that have the Build number in the Folder, path, install file name, registry etc...
Thanks
Geoff Coope
sealite
21st February 2003 16:26 UTC
I don't like the method
This method is not very usefull and slow down the compilation process.
kichik
21st February 2003 16:36 UTC
Compiling one installer one time is a lot faster than letting NSIS parse your script for __DATE__ and __MYPROG.EXE_VERSION__.