This question already has answers here:
How to declare an Inno Setup preprocessor variable by reading from a file
(4 answers)
Closed 3 years ago.
In my requirement, I need to set the value for the Global variables dynamically during run time. I need to read the name of the product which is stored in a text file and set it to the Global variables MyAppName and MyAppVerName during run time. For eg: If the text file has the value as Innovation, and my global variables will be as mentioned below in the iss file:
#define MyAppName "ABC ProductName Database"
#define MyAppVerName "ABC ProductName Database 1.0.0"
Here the ProductName must be replaced by Innovation. The reading of text from the file and getting the value part is clear for me. But how to handle this and set the value dynamically for the global variables mentioned?
Thanks in advance!.
This worked for me in my script.
[Setup]
AppName=ABC {#ProductName} Database
then when executing via cmd,
iscc "/dProductName=Innovation" "c:\example\script.iss"
Related
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?
This question already has answers here:
Save Inno Setup custom page field values to an INI file
(3 answers)
Closed 5 years ago.
I need to set values to an ini File, I try to search how to do it but I can't find an answer, the ini File is like:
[mysqld]
port=${one.port}
I wan to tho similar to:
[mysqld]
port=EditPort.text
Use SetIniString Function
From Inno Setup Help,
SetIniString writes a string to an INI file.
You can use it like
SetIniString('mysqld', 'port', EditPort.Text, ExpandConstant('<< PATH TO YOUR .INI 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.
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.
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: