Changing AppName and AppDir depending on language in Inno Setup - inno-setup

It's been a while since I was reading some questions/answers concerning InnoSetup, but none of them seems to help me... I want to change the AppName value depending on the language selected, being available English and Spanish. So, if the language chosen when prompted the dialog were Spanish, the AppName value should be "La Bola"; otherwise, if chosen English, the AppName value should be "The Ball".
The same thing applied to the AppDir. The only thing I've found so far was this Inno setup and DefaultDirName, but I cannot make it work with the Languages. Also tried using ISPP conditionals following an example:
#ifdef AppEnterprise
#define AppName "My Program Enterprise Edition"
#else
#define AppName "My Program"
#endif
but yet I cannot make it work with the Language, since I don't know how.
Is it possible to change it? =/
Greetings!

I had the same question, so I'm posting an answer that would allow others to get it faster.
Actually, there is an example in Examples\Languages.iss file in Inno Setup installation folder.
To be short:
[Setup]
AppName={cm:MyAppName}
then
[Languages]
Name: en; MessagesFile: "compiler:Default.isl"
Name: es; MessagesFile: "compiler:Languages\Spanish.isl"
then
[CustomMessages]
en.MyAppName=The Ball
es.MyAppName=La Bola
That's it. For more details, see the example. By the way, note that there is a LicenseFile language attribute available (this is not mentioned in the example):
[Languages]
Name: en; MessagesFile: "compiler:Default.isl"; LicenseFile: "eula_en.rtf"
Name: es; MessagesFile: "compiler:Languages\Spanish.isl"; LicenseFile: "eula_es.rtf"

Look at CustomMessages which can be translated into different languages, These can then be used in AppName and DefaultDirName with the {cm:..} constant.

ISPP is a Pre-Processor, so this means this code run's prior to compiling the SETUP.EXE
The AppName is used for a variety of purposes but one is the SETUP.EXE Resource. Which is why it can't be set at runtime using {code: }
So you could a compile time and have a different SETUP.EXE for each language.
You can do this in a number of ways, using the ISPP, here is one.
#define lang = "english"
[Setup]
#if lang == "english"
AppName=The Ball
#elif lang == "spanish"
AppName=La Bola
#else
# error Unsupported Language
#endif
AppVersion=1.5
;AppVerName=My Program 1.5
DefaultDirName={pf}\My Program
[Languages]
#if lang == "english"
Name: "en"; MessagesFile: "compiler:Default.isl"
#elif lang == "spanish"
Name: "spanish"; MessagesFile: "compiler:Languages\Spanish.isl"
#else
# error Unsupported Language
#endif
[Files]
Source: "C:\Program Files (x86)\Inno Setup 5\Examples\MyProg.exe"; DestDir: "{app}"; Flags: ignoreversion

Related

Inno Setup constants and parameters [duplicate]

This question already has answers here:
Passing in version number to Inno Setup compiler
(3 answers)
Closed 2 years ago.
I'm trying to add a parameter to my setup file, with a default value.
In this case I get a compile error at
OutputBaseFilename=MyApp {param:Version|{#MyAppVersion}} Setup
Saying:
Value of [Setup] section directive "OutputBaseFilename" is invalid
Shortened reference code:
#define MyAppName "My App"
#define MyAppVersion "1.7.24"
[Setup]
AppName={#MyAppName}
AppVersion="{param:Version|{#MyAppVersion}}"
DefaultGroupName=VHStudio
OutputBaseFilename=MyApp {param:Version|{#MyAppVersion}} Setup
SetupIconFile={#PathToRepoRoot}\Development\VHS\VHSStudio\media\logo.ico
[Icons]
Name: "{group}\VHStudio {param:version|MyAppVersion}"; Filename: "{app}\VHStudioApp.EXE"; WorkingDir: "{app}"
Name: "{group}\Uninstall VHStudio"; Filename: "{app}\unins000.exe"; WorkingDir: "{app}"
Name: "{userdesktop}\{#MyAppName}"; Filename: "{app}\VHStudioApp.EXE"; Tasks: desktopicon
I'm guessing I'm using the constant wrong?
The Strange thing is that I do
AppVersion="{param:Version|{#MyAppVersion}}"
Without any errors...
Based on the comment from Martin. Suggesting to take a look at Passing in version number to Inno Setup compiler.
Turns out I overcomplicated things. You can easily pass parameters to the compiler for pre-processor variables. In my situation MyAppVersion.
What I did in Inno Setup:
#ifndef MyAppVersion
#define MyAppVersion "1.7.24"
#endif
And when compiling it looks like this:
ISCC.exe myProg.iss /DMyAppVersion=1.7.14

how to change the icon of the shortcut of accde in inno setup

Everyone I created a DB and after that, I compile it ACCDE and I use Inno setup for making installer of ACCDE file but I have a problem I want to change the Icon of the shortcut which is created by inno setup on the Desktop. Any idea how to perform this task. Thanks in advance.
Put down {commondesktop} as Name in the Icons section, if you want to make a shortcut on the Desktop Window. That's all.
Assume the name of your ACCDE is "example.accde".
See below.
#define MyAppName "Example"
#define MyAppFullVersion "0.1.0"
#define MyAccdeFileName "example.accde"
[Setup]
AppId={{2D9CC75F-E3DA-4E86-A659-03301DDE1C33}}
AppName={#MyAppName}
AppVerName={#MyAppName} {#'V'}{#MyAppFullVersion}
DefaultDirName={pf}\{#MyAppName}
[Files]
Source: "{#MyAccdeFileName}"; DestDir: "{app}"
[Icons]
Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAccdeFileName}"; WorkingDir: "{app}"
Use IconFilename parameter of your [Icons] section entry:
[Icons]
Name: "{commondesktop}\My DB"; Filename: "{app}\db.accde"; IconFilename: "{app}\myicon.ico"

UTF-8 characters not displaying correctly in Inno Setup

I've seen a couple of other threads about this but I've spent a while trying to get it sorted to no avail.
Here's a generic version of my .iss file:
; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
#define AppName "MyApp"
#define CompanyName "MyCompany"
#define FileName "File Name"
#define AppExeName "App Exe.exe"
#define AppIcon "..\icon.ico"
#define AppId "app.id"
#define AppURL "mywebsite"
#define AppSrcDir "path\to\app\directory"
#define AppTargetDir "{userappdata}\" + CompanyName + "\" + AppName
#define AppVersion GetFileVersion(AppSrcDir + "\" + AppExeName)
#define AppPublisher "Publisher"
#define LaunchMessage "Launch Message"
#define AppProtocol "protocol"
#define OutputDir "path\to\output"
#define SetupFilename FileName + "-setup-" + AppVersion
#define SetupImage "..\setup.bmp"
#define InstallerMessage "Some message with a German character - ö"
[Setup]
; NOTE: The value of AppId uniquely identifies this application.
; Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AllowCancelDuringInstall=no
AppId={#AppId}
AppName={#AppName}
AppVersion={#AppVersion}
AppVerName={#AppName} {#AppVersion}
AppPublisher={#AppPublisher}
AppPublisherURL={#AppURL}
AppSupportURL={#AppURL}
AppUpdatesURL={#AppURL}
DefaultDirName={#AppTargetDir}
DefaultGroupName={#CompanyName}
DisableDirPage=yes
DisableProgramGroupPage=yes
DisableReadyPage=yes
DisableReadyMemo=yes
OutputDir={#OutputDir}
OutputBaseFilename={#SetupFilename}
PrivilegesRequired=lowest
SetupIconFile={#AppIcon}
SignTool=signtool
Compression=lzma/ultra64
SolidCompression=yes
WizardSmallImageFile={#SetupImage}
UninstallDisplayIcon={app}\{#AppExeName}
[InstallDelete]
Type: filesandordirs; Name: {#AppTargetDir}
[Languages]
Name: de; MessagesFile: "compiler:Languages\German.isl"
[Files]
Source: "{#AppSrcDir}\*"; DestDir: "{app}"; Flags: recursesubdirs
Source: "path\to\other\installers\win32\*"; DestDir: "{app}\redist";
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
[Icons]
Name: "{group}\{#AppName}"; Filename: "{app}\{#AppExeName}"; WorkingDir: "{app}";
Name: "{commondesktop}\{#AppName}"; Filename: "{app}\{#AppExeName}"; WorkingDir: "{app}";
[Run]
FileName: "{app}\redist\installer.exe"; Parameters: "/S /v/qn"; WorkingDir: "{app}"; StatusMsg: "{#InstallerMessage}";
The problem I have is that it doesn't display the InstallerMessage text correctly. The ö character does not render correctly.
I am using the Unicode version of Inno Setup (with the "(u)").
I have seen some mentions of using a byte order mark but I haven't seen any examples. I tried converting the whole string using a UTF-8 encoder and added the byte order mark at the start but it didn't work. I'm completely stumped!
Make sure your .iss file uses UTF-8 encoding with BOM.
And of course, you need Unicode version of Inno Setup (the only version as of Inno Setup 6).
Was the string also used in Pascal Script code (what is not, mentioning it just for benefit of others, who may find this question), you also have to use Inno Setup 5.6.0 or later. Earlier versions did not support UTF-8 in Pascal Script.
Pascal Scripting changes:
Unicode Inno Setup: Unicode is now supported for the input source. For example, where before you had to write S := #$0100 + #$0101 + 'Aa'; you can now write S := 'ĀāAa'; directly. Also see the new UnicodeExample1.iss example script.
See also Inno Setup Unicode encoding issue with messages in ISS script.

How to save to Windows registry the language chosen when setup.exe (from INNO 5.5.4) is executed?

I have a Build (*.iss) file for INNO that gives the user the possibility of choosing between 4 languages when the setup.exe is executed. I would like the language chosen by the user to be saved in the Windows registry (or in a file where the setup.exe is located). This would be used as input to the installed program. The installed program will then dynamically change the language used for the menu items/messages to the language chosen by the user.
How can I this task be accomplished in the INNO *.iss file?
You can store the value given by the {language} constant. It returns the selected language identifier name (the name specified by the Name parameter of the [Languages] section entry). For instance, the following script will store either en or nl value (depending on which language the user selects) to the specified registry key:
[Setup]
AppName=My Program
AppVersion=1.5
DefaultDirName=My Program
[Languages]
Name: "en"; MessagesFile: "compiler:Default.isl"
Name: "nl"; MessagesFile: "compiler:Languages\Dutch.isl"
[Registry]
Root: HKLM; Subkey: "Software\My Company\My Program\Settings"; ValueType: string; ValueName: "Language"; ValueData: "{language}"
In a code you can query the ActiveLanguage function, which returns the same language identifier as the {language} constant. To store this identifier into a text file in the form you've mentioned after the installation is done, you can use the following code:
[Setup]
AppName=My Program
AppVersion=1.5
DefaultDirName=My Program
[Languages]
Name: "en"; MessagesFile: "compiler:Default.isl"
Name: "de"; MessagesFile: "compiler:Languages\German.isl"
[Code]
procedure CurStepChanged(CurStep: TSetupStep);
var
S: string;
begin
if CurStep = ssPostInstall then
begin
S := Format('language = "%s"', [ActiveLanguage]);
SaveStringToFile('C:\File.txt', S, False);
end;
end;

Registry based components with Inno Setup

I'm creating an application for my company. And the goal is to create a universal installer that will be checking user's registry for specific apps installed and according to these apps would create a list of available installation components in "Select Components" window. And that's the particular problem I'm stacked with.
I've already created the installer, but a user have to check/uncheck components he doesn't need because he doesn't use specific app. That is definitely not a good way of doing thing I guess...
So I'm asking for help, please. Could this be implemented through "Select Components" window and how or I should create custom wizard page with checkboxes (again - How)?
Many thx in advance.
P.S. I've already used Check function in my script, but in this case the program automatically installs all of the components related to found apps on users machine, and sometimes users don't need that....
This removes a component based on a registry value. You'd want to modify this to fit each application you are trying to install and would probably need a Check function for each application.
; -- Components.iss --
; Demonstrates a components-based installation.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING .ISS SCRIPT FILES!
[Setup]
AppName=My Program
AppVerName=My Program version 1.5
DefaultDirName={pf}\My Program
DefaultGroupName=My Program
UninstallDisplayIcon={app}\MyProg.exe
OutputDir=userdocs:Inno Setup Examples Output
[Types]
Name: "full"; Description: "Full installation"
Name: "compact"; Description: "Compact installation"
Name: "custom"; Description: "Custom installation"; Flags: iscustom
[Components]
Name: "program"; Description: "Program Files"; Types: full compact custom; Flags: fixed
Name: "help"; Description: "Help File"; Types: full; Check: IsMyAppInstalled
Name: "readme"; Description: "Readme File"; Types: full
Name: "readme\en"; Description: "English"; Flags: exclusive
Name: "readme\de"; Description: "German"; Flags: exclusive
[Files]
Source: "MyProg.exe"; DestDir: "{app}"; Components: program
Source: "MyProg.chm"; DestDir: "{app}"; Components: help
Source: "Readme.txt"; DestDir: "{app}"; Components: readme\en; Flags: isreadme
Source: "Readme-German.txt"; DestName: "Liesmich.txt"; DestDir: "{app}"; Components: readme\de; Flags: isreadme
[Icons]
Name: "{group}\My Program"; Filename: "{app}\MyProg.exe"
[Code]
function IsMyAppInstalled(): Boolean;
Var
installed: String;
begin
if RegQueryStringValue(HKEY_CURRENT_USER, 'Software\MyApp',
'Installed', installed) then
result := true
Else
result := false;
end;
What you want to do goes beyond Inno Setup design, and I think you need to write your own installer instead of using a generic installer framework such as Inno Setup.

Resources