Where does GetVersionNumbersString take data from in Inno Setup? - inno-setup

In order to get the file version I wrote this:
#define FileVersion GetVersionNumbersString("...\Client.exe")
[Setup]
VersionInfoVersion={#FileVersion}
File version is a string in "0.0.0.0" format. In my case it's 5.0.6.5 and it does not change.
Where does GetVersionNumbersString take that data from? How is 5.0.6.5 formed?

The version is taken from the version info of your .exe file. If you check the "Details" tab of the executable properties, the GetVersionNumbersString corresponds to the "File version" entry (5.17.9.10905 in this case):

Related

How to add application version to Inno Setup startup message?

With Inno Setup, if we choose to keep the prompt dialog (DisableStartupPrompt=False) the displayed message is managed by the localization file with the reference SetupLdrStartupMessage. For instance in English locale file:
SetupLdrStartupMessage=This will install %1. Do you wish to continue?
By default the setup will replace %1 by the name of the application defined by the variable AppName. How to make the text display AppVerName instead ?
I would like to get the following text :
This will install MyApplicationName 4.1. Do you wish to continue?
The Pascal function InitializeSetup() is not a correct option for me for two reasons:
This section is called after the language selection, called itself after the startup prompt. I want to keep this first popup.
It imply to re-write as many custom message as language you manage.
Make the version be part of the message:
#define MyAppVer "4.1"
[Setup]
AppName=MyApplicationName
AppVersion={#MyAppVer}
[Messages]
SetupLdrStartupMessage=This will install %1 {#MyAppVer}. Do you wish to continue?

How to get the file name of the current Inno Setup script file?

I want to obtain the name of the current Inno Setup script file in order to name the generated setup package after it. For example if the current Inno Setup script file is "MyAppSetup.iss", I want the generated setup file to be "MyAppSetup.exe".
The name of the generated setup file is controlled by the OutputBaseFilename declaration in the [Setup] section of Inno Setup, so if there's an Inno Setup preprocessor variable that returns the name of the current script file that would be great. Something like:
OutputBaseFilename={#SourceFileName}.exe
Unfortunately, there isn't an Inno Setup preprocessor variable {#SourceFileName}. I know about the {#SourcePath} variable, but it returns the directory path of the script file without it's file name. Here's a list with some predefined Inno Setup preprocessor variables, but none of them seems to return the name of the current script file. I hoped the __FILE__ variable would work after reading the descriptions of the variables in the list, but it returns an empty string.
It's not possible. There's the __FILE__, but it has a value for #included files only.
If you never have more than one .iss file in a directory, you can use the FindFirst to find its name.
#define ScriptFindHandle = FindFirst(SourcePath + "\*.iss", 0)
#if !ScriptFindHandle
#error "No script found"
#endif
#define SourceFileName = FindGetFileName(ScriptFindHandle)
#if FindNext(ScriptFindHandle)
#error "More than one script found"
#endif
#expr FindClose(ScriptFindHandle)
#define SourceBaseName = RemoveFileExt(SourceFileName)
Then to name the setup file after the current script file in the [Setup] section you should use:
[Setup]
OutputBaseFilename={#SourceBaseName}
But if you are automating compilation of a large number of installers, I assume you use a command-line compilation. So then you can simply pass a script name in a parent batch file (or a similar script):
set SCRIPT=MyAppSetup
"C:\Program Files (x86)\Inno Setup 5\ISCC.exe" %SCRIPT%.iss /DBaseName=%SCRIPT%
Use the BaseName like:
[Setup]
OutputBaseFilename={#BaseName}
I know this is not exactly what you want, but why can't you do this:
[ISPP]
#define ScriptFileName "MyAppSetup"
[Setup]
AppPublisher={#AppPublisher}
OutputBaseFilename={#ScriptFileName}Setup
Then all you need to do it edit the one reference at the top of your file.
Update
I came across this link where it states:
You can use:
#expr SetSetupSetting("OutputBaseFilename", sFileName)
However, the difficult part is automatically finding the file name.
You could use the following ISPP functions to do additional
compile-time tasks that can't be done by ISPP built-in functions:
Exec function: Executes an external program to do the additional
functionality, and writes the result to an INI file. By default Exec
waits for the process to finish.
ReadIni function: Reads the result
from the INI file, and incorporates it into the script.
How do you determine the file name is up to you. Perhaps you could
enumerate the windows and extract the file name from Inno Setup
window title, but because you may be having multiple Inno Setup
copies open, you must find a reliable way to do it. Inno adds
[Compiling] to the title during compilation which makes it easier to
find which copy is being used, but there could be multiple copies in
compiling state. You can be absolutely sure about which copy is
running your program by checking the process ID of the parent
process, you can get that by using Process32First/Process32Next and
checking the 32ParentProcessID for your process. Too much work, I
know..
But there was another comment:
(If you're doing an automated build, though, you can set the output
filename from the command line -- that might be sufficient for what
you actually want.)
So have you considered using a batch file and the command line? Then you can use the benefits of batch lines with your compiling. Information is provided here about using the current file name in batch files.
I personally think that the batch file compilation is the way to go.

How to set inno setup script parameters from final builder?

I am new to Final Builder 7 and got some work on it.
I want to set minor version from Final Builder 7 to inno setup script by asking user to enter the minor version number.
I have defined user variable called minor, which is set by asking user input, I want to use this variable in one of the .iss files in the project.
Any clue?
Thanks in advance.
--
With best regards
Amol
I solved this using following script:
#define AppVersion GetFileVersion("MyApp.exe")
#define Major
#define Minor
#define Rev
#define Build
#define Version ParseVersion("MyApp.exe", Major, Minor, Rev, Build)
[Setup]
AppName=MyApp
AppVerName={#AppVersion}
VersionInfoVersion={#AppVersion}
AppVersion={#AppVersion}
OutputBaseFilename=5{#Build}
-- Cheers
Looks like you are looking for user input. We run many builds many times every day and user never needs to enter anything.
Final builder 7 has version control, or you can increment variable. We use combination of that. So, Final builder has the version, we don't touch it. For example, final builder has 1.1.2 and it also has incremental variable. In the end we get 1.1.2.345 where 345 is automatically incremented build number.
Now, how we update Inno to the appropriate version. In our scripts we have #define(s) listed like this
#define Major "##major##"
#define Minor "##minor##"
#define Anything "##anything##"
Where ##....## is a placeholder. Before running Inno script we execute Text Find / Replace action and our placeholders are replaced with real data. Then we execute Inno using Run DOS Command / Batch File action and executing something like this
iscc.exe "%BaseDir%\Install Files\MyLovelyInstallScript.iss"
This way, there is no need for user input, unless your software changes version completely. Then, we just change variables that represent numbers in 1.1.2 - a rare event.

Using INI file to fill setup section values on inno setup

I'm trying fill setup section values with {param} and {ini} like this:
VersionInfoProductName={param:NAME|My Product}
VersionInfoTextVersion={ini:ExpandConstant({src})\config.ini,setupValues,version|unknow}
But it is not working, in EXE properties is showing {param:NAME|My Product}
I also tried with GetIniString but same result.
How can I put ini values in Setup section?
You cannot use any of the constants you have used, because both directives you're trying to fill need to be filled at compilation time. You will need to use the preprocessor function equivalent, because only the preprocessor can fill the directive values before the compilation starts.
The preprocessor's equivalent for reading from INI files is the ReadIni function, which you can use the way which follows. Assuming you have a config.ini file stored in the same location as the script with this content:
[setupValues]
version=1.2.3.0
You can fill the value of the VersionInfoVersion directive this way. I have used this directive, since the value of the VersionInfoTextVersion directive is displayed only on Windows 98 below systems and I believe you're not running such an old system to ever verify this:
[Setup]
VersionInfoVersion={#ReadIni(SourcePath + "config.ini", "setupValues", "version", "")}
Note, that the SourcePath variable used in the above code is a predefined variable that can be evaluated from preprocessor. The result you can then verify by checking the setup binary file properties and you will see e.g. this:

Inno-Setup checking file location prior to installation, then using it during installation

I need to check for the location of a file during program installation utilizing inno setup. I then need inno setup to use the location of that file in the "Filename" line to create a desktop ICON for program initialization. I have the code for the "Icons" option working fine with the exception of how to do the above.
Here is the line of code I am currently using;
Name: "{commondesktop}\SA - NH Bricscad V12"; Filename:"**c:\program files\septic assistant\new hampshire\support\**SA - NH Bricscad V12.exe"; IconFilename: "C:\Program Files\Septic Assistant\New Hampshire\Support\Bricscadlogo.ico"; Comment: "Septic Assistant the only Septic Design Program"
Hi-Lited section would be the path to the exe file that I need inno setup to search for.
Any assistance with this would be very much appreciated.
Bruce
Just use a {code:...} constant and corresponding [Code] function that returns the appropriate path for your [Icons] entry. You will probably also want to use a Check function to avoid installing the icon in the case that you cannot find the correct location.
Another option is to use a {reg:...} constant, assuming that the path you are trying to locate is specified somewhere in the registry (which is usually the case).
If the path is not already specified somewhere well-defined in the Registry when the other app is installed, and you don't have some other means to quickly identify where the other app is located (note that doing a global search of the user's HD is not a valid option), then you should add a page that prompts the user to enter the location themselves (which you can then verify that they have chosen the correct location). You can see examples of prompting the user for information and then doing something with that info in the CodeDlg.iss example included with Inno, and in the ISXKB wiki.

Resources