Get Application Version

38 views
Skip to first unread message

Dan Bomsta

unread,
Feb 26, 2026, 10:41:40 AM (12 days ago) Feb 26
to innosetup
I have used Inno Setup many years ago and the following worked well
#define MyAppVersion GetStringFileInfo( "AddBackslash(SourcePath) + \someApp.exe", "ProductVersion" )

Now using version 6.7.1 GetStringFileInfo and GetVersionNumbersAsString to do work.  So I added a function, which successfully retrieves the version info.
/////////////////////////////////////////////////////////////////////
function GetVersion(Param: String): String;
  var
    Version: String;
    Filename : String;
begin
    Result := '0.0.0.0';
   
    Filename := ExpandConstant('{app}\someApp.exe');
    Log('ExapandConstant returned: ' + Filename );
    if (GetVersionNumbersString(ExpandConstant('{app}\someApp.exe'), Version) ) then
      begin
        Log('Version info: ' + Result);
        Result := Version;
      end;
end;

Then I figured in [Setup] I could use the GetVersion function with OutputBaseFilename={#SetupBaseName}{code:GetVersion}.  The compiler does not like this though it works in the sample script CodeExample1.iss

I am unsure what else to try.  Any advice is appreciated.


Martijn Laan

unread,
Feb 26, 2026, 10:46:50 AM (12 days ago) Feb 26
to innosetup
Hi,

Op 26-2-2026 om 16:33 schreef 'Dan Bomsta' via innosetup:
I have used Inno Setup many years ago and the following worked well
#define MyAppVersion GetStringFileInfo( "AddBackslash(SourcePath) + \someApp.exe", "ProductVersion" )


The first quote is in the wrong place, so I do not think this can have ever worked. There is also an extra, unneeded backslash.

This works for me:

#define MyAppVersion GetStringFileInfo(AddBackslash(SourcePath) + "someApp.exe", "ProductVersion")

Which can be written shorter as:

#define MyAppVersion GetFileProductVersion(AddBackslash(SourcePath) + "someApp.exe")

Then I figured in [Setup] I could use the GetVersion function with OutputBaseFilename={#SetupBaseName}{code:GetVersion}.

Using {code:} does not work here because it is runtime functionality, not compile time.

Greetings,
Martijn

Dan Bomsta

unread,
Feb 26, 2026, 10:55:12 AM (12 days ago) Feb 26
to innosetup
Hi Martijn,
Thank you for the quick reply.  I have tried both defines you shared; neither are working for me.

scriptScreenshotVersion.png

outputScreenshot.png

jeff weir

unread,
Feb 26, 2026, 12:18:44 PM (12 days ago) Feb 26
to innosetup
FWIW, I use this to get the string you are looking for:

#define verinfo_file_version GetVersionNumbersString("{full_path_to_exe}")

Martijn Laan

unread,
Feb 26, 2026, 1:01:23 PM (12 days ago) Feb 26
to innosetup
This means the file does not exist, or does not have a product version in its version info. 

Greetings,
Martijn 


-------- Original Message --------

On Thursday, 02/26/26 at 16:55 'Dan Bomsta' via innosetup <inno...@googlegroups.com> wrote:
Hi Martijn,
Thank you for the quick reply.  I have tried both defines you shared; neither are working for me.




On Thursday, February 26, 2026 at 9:46:50 AM UTC-6 Martijn Laan wrote:
Hi,

Op 26-2-2026 om 16:33 schreef 'Dan Bomsta' via innosetup:
I have used Inno Setup many years ago and the following worked well
#define MyAppVersion GetStringFileInfo( "AddBackslash(SourcePath) + \someApp.exe", "ProductVersion" )


The first quote is in the wrong place, so I do not think this can have ever worked. There is also an extra, unneeded backslash.

This works for me:

#define MyAppVersion GetStringFileInfo(AddBackslash(SourcePath) + "someApp.exe", "ProductVersion")

Which can be written shorter as:

#define MyAppVersion GetFileProductVersion(AddBackslash(SourcePath) + "someApp.exe")

Then I figured in [Setup] I could use the GetVersion function with OutputBaseFilename={#SetupBaseName}{code:GetVersion}.

Using {code:} does not work here because it is runtime functionality, not compile time.

Greetings,
Martijn

--
You received this message because you are subscribed to the Google Groups "innosetup" group.
To unsubscribe from this group and stop receiving emails from it, send an email to innosetup+...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/innosetup/1bf22984-e80e-4ea0-bbcb-7e07a213a9c5n%40googlegroups.com.

Martijn Laan

unread,
Feb 26, 2026, 1:02:16 PM (12 days ago) Feb 26
to innosetup
Hi,

That doesn't get the product version though.

Greetings,
Martijn


-------- Original Message --------
--
You received this message because you are subscribed to the Google Groups "innosetup" group.
To unsubscribe from this group and stop receiving emails from it, send an email to innosetup+...@googlegroups.com.

jeff weir

unread,
Feb 26, 2026, 2:01:13 PM (12 days ago) Feb 26
to innosetup
Right! 

How about this - assuming the version info is 'correct':

#define verinfo_file_version GetVersionNumbersString(verinfo_source)
#define verinfo_product_name GetStringFileInfo(verinfo_source, PRODUCT_NAME)
#define verinfo_product_version GetFileProductVersion(verinfo_source)

AppName={#verinfo_product_name}
AppVerName={#verinfo_product_name} {#verinfo_product_version}
AppVersion={#verinfo_file_version}
OutputBaseFilename={#output_filename_prefix}_{#verinfo_file_version}

I can confirm all those work on 6.7.1 ;-)

Dan Bomsta

unread,
Feb 26, 2026, 2:20:06 PM (12 days ago) Feb 26
to innosetup
Jeff's second solution works, I didn't try the first.  I defined verinfo_source as the full path string to the exe.

It is unclear why the usual way #define MyAppVersion GetFileProductVersion(AddBackslash(SourcePath) + "someApp.exe") is not working.  At least I have a working solution now.

Dan Bomsta

unread,
Feb 26, 2026, 2:20:37 PM (12 days ago) Feb 26
to innosetup
Sorry...Thank you all for your assistance!

jeff weir

unread,
Feb 26, 2026, 3:04:27 PM (12 days ago) Feb 26
to innosetup
Jeff's second solution works, I didn't try the first.  I defined verinfo_source as the full path string to the exe.

Oops, I forgot to include that part! I'm happy it worked out for you.

Gavin Lambert

unread,
Feb 26, 2026, 5:31:03 PM (12 days ago) Feb 26
to innosetup
On Friday, February 27, 2026 at 8:20:06 AM UTC+13 Dan Bomsta wrote:
Jeff's second solution works, I didn't try the first.  I defined verinfo_source as the full path string to the exe.

It is unclear why the usual way #define MyAppVersion GetFileProductVersion(AddBackslash(SourcePath) + "someApp.exe") is not working.  At least I have a working solution now.

Was your exe actually in the same folder as the main .iss script?  That's what SourcePath means in ISPP; it has no relationship to the SourceDir [Setup] setting. 

Martijn Laan

unread,
Feb 27, 2026, 3:44:28 AM (12 days ago) Feb 27
to innosetup


Op 26-2-2026 om 20:20 schreef 'Dan Bomsta' via innosetup:
Jeff's second solution works, I didn't try the first.  I defined verinfo_source as the full path string to the exe.

It is unclear why the usual way #define MyAppVersion GetFileProductVersion(AddBackslash(SourcePath) + "someApp.exe") is not working.  At least I have a working solution now.

GetFileProductVersion gets the textual product version of your file. Jeff is using GetVersionNumbersString, which instead gets the binary file version of your file as text.

If the former is working but the latter is not, it just means your file has no textual product version set.

Note that there is also GetFileVersionString, which gets a third version, the textual file version. In case you are not aware, the textual and binary file versions are two truly distinct fields in a file's version info.

To make matters worse, there is a fourth version in a file's version info, the binary product version, again a truly distinct field. However, I do not think there is a function to get this value.

Greetings,
Martijn

Bomsta, Dan

unread,
Feb 27, 2026, 9:18:23 AM (11 days ago) Feb 27
to innosetup
Thank you again to all of your for the information.

I can go back to using #define MyAppVersion GetStringFileInfo( AddBackSlash( SourcePath ) + "LabWingman.exe", "ProductVersion" ) by based on Gavin's response.  The Inno script and the executable were in different directories.  Placing the Inno script in the same directory allows one to use the aforementioned define.  Well, it has been a decade or so since I last used Inno Setup...the things we forget ;-)

Dan

From: 'Martijn Laan' via innosetup <inno...@googlegroups.com>
Sent: Friday, February 27, 2026 2:44 AM
To: innosetup <inno...@googlegroups.com>
Subject: [EXTERNAL] Re: Get Application Version
 
Op 26-2-2026 om 20: 20 schreef 'Dan Bomsta' via innosetup: Jeff's second solution works, I didn't try the first.   I defined verinfo_source as the full path string to the exe. It is unclear why the usual way #define MyAppVersion GetFileProductVersion(AddBackslash(SourcePath)
ZjQcmQRYFpfptBannerStart
Caution! This email is from someone new.
You have not previously corresponded with this sender, are you familiar with this email address or expecting a message from this email address? If you suspect a phishing attempt, please report it using the Phish Alert Report button.
 
ZjQcmQRYFpfptBannerEnd
--
You received this message because you are subscribed to a topic in the Google Groups "innosetup" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/innosetup/29gk1-EgrYY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to innosetup+...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/innosetup/177218186212.7.10611471796698221709.1199203870%40innosetup.nl.
Reply all
Reply to author
Forward
0 new messages