7

I would like to read these three values from my application.exe in my Inno Setup script.

[assembly: AssemblyCompany("My Company")]
[assembly: AssemblyProduct("My Great Application")]
[assembly: AssemblyFileVersion("9.3.2")]

Does anyone know how this might be accomplished?

I know I can get the last one using GetFileVersion("path/to/greatapp.exe") is there something similar for the first two?

Community
  • 1
  • 1
Nifle
  • 11,745
  • 10
  • 75
  • 100
  • I don't think that's doable as those attributes are .NET specific. Unless you write your own extension to achieve that goal. So I end up with hard coding them in my script. – Lex Li Sep 17 '09 at 06:57

2 Answers2

12

Use the GetStringFileInfo() function provided by the Inno Setup Preprocessor (ISPP) as follows:

  1. GetStringFileInfo("path/to/greatapp.exe", "CompanyName")
  2. GetStringFileInfo("path/to/greatapp.exe", "ProductName")
  3. GetStringFileInfo("path/to/greatapp.exe", "FileVersion")

As you have already mentioned, you can use the GetFileVersion() function instead of #3 above.

Also, have a look at the ISPPBuiltins.iss script file included with your Inno Setup installation. It contains a GetFileCompany() function to use instead of #1 above and you can implement #2 above in a similar fashion.

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
Bernard
  • 7,908
  • 2
  • 36
  • 33
0

I dont know Inno Setup but I guess it supports custom actions like the other setup tools (Visual Studio, Wix, InstallShield or Wise).

So, you will need to create a custom action to read this information from the assembly. In your custom action, you need to add the following code to fetch the assembly attributes:

Assembly assembly  = Assembly.LoadFrom (@"path\to\greatapp.exe");
object[] attributes = assembly.GetCustomAttributes(true);

if (attributes.Length > 0)
{
    foreach (object o in attibutes) 
    {
        //Do Something with the attribute
    }
}
Francis B.
  • 7,018
  • 2
  • 32
  • 54
  • It can take a lot of effort, as usually Inno Setup extensions are not authored in .NET, which means you need to parse the file manually on your own to query the attributes. – Lex Li Sep 17 '09 at 06:58
  • I stumbled across this somewhere and this seems to work: #define MyAsmVersion GetStringFileInfo("C:\ProjectFolder\bin\Release\" + ExeName,"Assembly Version") It seemed to need a space between 'Assembly' and 'Version' – TonyM Dec 01 '17 at 12:56