I'm using Inno Script Studio to build an installer, so far very successfully as Inno Setup is a great package.
However, I want to add a warning page which is displayed when the user unchecks an important Task. I thought this would just be an easy check. After some Googling, I realised that this will require some Pascal scripting - something that I unfortunately have no knowledge of (evidence below)...
begin
if not IsTaskSelected('ImportantTask') then
WarningPage := CreateOutputMsgPage(wpSelectTasks, 'Caution',
'Please read the following important information before continuing.',
'You have not selected the ImportantTask option. Click "Back" to
reselect ImportantTask, or click "Next" to continue at your own risk.');
end;
Unsurprisingly, this didn't work.
Here are the requirements:
ImportantTask is to be checked by default.
If ImportantTask is unselected then display WarningPage with Risk Acknowledgement checkbox.
If risk acknowledgement checkbox is unticked, disable the Next button.
I didn't want to end up with a large [Code] section, but there is possibly no other option.
Thanks in advance for the help.
Use msgbox's instead wizard pages. Msgbox's are especially used for Giving any indication(info,warning..etc) to user..
This script works as per your requirement.
[Setup]
AppName=MySetup
AppVersion=1.5
DefaultDirName={pf}\MySetup
[Tasks]
Name: "ImportantTask"; Description: "This task should be selected"; GroupDescription: "Important tasks";
[Code]
function NextButtonClick(CurPageID: Integer): Boolean;
begin
Result := True;
if (CurPageID = wpSelectTasks) and not IsTaskSelected('ImportantTask') then
Result := Msgbox('You have not selected the ImportantTask option.' + #13#10 +
'Are you sure you want to continue ?', mbInformation, MB_YESNO) = IDYES;
end;
credit goes to TLama...
Related
For our purposes, we decided to use Inno Download Plugin and Inno Setup version 6.2.0
We switched the installer to silent mode to get rid of unnecessary windows and buttons. It turned out somehow like this (I don’t attach idp.iss, it’s unchanged)
[code]https://pastebin.com/g7xb6iWj
Everything works fine, but there are a couple of but:
1 There is a Downloading window called by IDP, click on the cross to close the window and in the modal window that appears, confirm with Yes
Instead of aborting the download, it tries to proceed with the installation and creates shortcuts
2 There is a Downloading window called by IDP, turn off wifi, in the modal window that appears where they say "Internet is gone" and ask "Retry or Cancel?" click Cancel
Instead of aborting the download, it tries to proceed with the installation and creates shortcuts
I found an explanation here
Exit from Inno Setup installation from [Code]
But I can't figure out exactly how to catch buttons in specific modal windows.
And if I'm not mistaken, the second interrupt case is not native and only applies to IDP
Any ideas to right cancelation of installation of those 2 cases would be great.
My friend did a solution
procedure CurPageChanged(CurPageID: Integer);
begin
WizardForm.Bevel1.Visible := false;
WizardForm.MainPanel.Visible := false;
WizardForm.InnerNotebook.Top := 50;
WizardForm.OuterNotebook.height := 400;
if CurPageID = wpInstalling then begin
Downloaded := idpFilesDownloaded();
if not(Downloaded) then begin
ExitProcess(553);
end;
end;
end;
procedure CancelButtonClick(CurPageID: Integer; var Cancel, Confirm: Boolean);
begin
if Cancel = True then begin
ExitProcess(554);
end;
end;
Inno Setup will show different message boxes to the user.
For example,
When it tries to install a file that is in use, it will show a message to abort/ignore/cancel.
When the setup is installing the files and the target path will have low space while installing, the setup will give an error.
I need to customize these message boxes on my own. (I do not want these native messages to be shown to the user) for example, I need to show another message box, or even totally do not show a specific message from Inno Setup, or changing a label when that message is going to fire.
All Inno Setup messages can be customized using the [Messages] section.
Some examples:
How to modify error message in Inno Setup?
Show a custom message for unsupported architectures
How can I show my own message and then exit setup if the current version of Windows is not supported?
As for the change of the message box layout/design. You cannot really change it. With some fancy implementation of Check and BeforeInstall parameters, you might be able to catch some problems before Inno Setup detects them and handle them your custom way. But that's lot of work with unreliable results.
If you tell us what are you trying to achieve more specifically, you may get more specific answer.
If you need a solution that allows everything that Inno Setup allows on error, including clean abort of the installation, Check or BeforeInstall won't help as they do not have a way to cleanly abort it.
You would have to do all the checks before the installation, e.g. in CurStepChanged(ssInstall).
[Files]
Source: "MyProg.exe"; DestDir: "{app}"; Check: ShouldInstallFile
[Code]
var
DontInstallFile: Boolean;
function ShouldInstallFile: Boolean;
begin
Result := not DontInstallFile;
end;
procedure CurStepChanged(CurStep: TSetupStep);
var
FileName: string;
Msg: string;
Response: Integer;
begin
if CurStep = ssInstall then
begin
FileName := ExpandConstant('{app}\MyProg.exe');
repeat
if FileExists(FileName) and (not DeleteFile(FileName)) then
begin
Msg := Format('File %s cannot be replaced', [FileName]);
Response := MsgBox(Msg, mbError, MB_ABORTRETRYIGNORE)
case Response of
IDABORT: Abort;
IDIGNORE: DontInstallFile := True;
end;
end;
until (Response <> IDRETRY);
end;
end;
I am creating installer using Inno Setup. I have calculated available disk space using function GetSpaceOnDisk. I am displaying error message if available disk space is not enough, and then installer will not continue.
But before my error message displays, Inno Setup Disk space warning is shown with Yes/No option. How can I disable this warning?
You cannot disable the check, nor change the buttons.
What you can do, is to revert a meaning of a question in the message by overriding the default text using [Messages] section, to say something like:
Do you want to cancel installation?
If the user presses No, the installer stays on the Select Destination Location page. If the user presses Yes, the NextButtonClick(wpSelectDir) gets called. There you repeat the check for the disk space (to distinguish the call from a basic scenario, with no warning), and if there's not enough space, you abort the installer forcefully.
[Messages]
DiskSpaceWarning=Setup requires at least %1 KB of free space to install, but the selected drive only has %2 KB available.%n%nDo you want to cancel installation?
[Code]
function NotEnoughSpace: Boolean;
begin
Result := { Check disk space };
end;
procedure ExitProcess(exitCode:integer);
external 'ExitProcess#kernel32.dll stdcall';
function NextButtonClick(CurPageID: Integer): Boolean;
begin
if CurPageID = wpSelectDir then
begin
if NotEnoughSpace then
begin
ExitProcess(0);
end;
end;
Result := True;
end;
The ultimate solution is to re-implement the Select Destination Location page. It's not that difficult. It's just one edit box and one button.
I would like to swap the SelectDir page with the Components page in my setup.
I found a solution where the content of the other page is assigned to the current page.
Procedure CurPageChanged(CurPageID: Integer);
Begin
Case CurPageID of
wpSelectDir:
begin
WizardForm.SelectDirPage.Notebook.ActivePage:= WizardForm.SelectComponentsPage;
WizardForm.PageNameLabel.Caption:= SetupMessage(msgWizardSelectComponents)
WizardForm.Hint:= WizardForm.PageDescriptionLabel.Caption;
WizardForm.PageDescriptionLabel.Caption:= SetupMessage(msgSelectComponentsDesc)
end;
wpSelectComponents:
begin
WizardForm.SelectComponentsPage.Notebook.ActivePage:= WizardForm.SelectDirPage;
WizardForm.DiskSpaceLabel.Caption:= WzardForm.ComponentsDiskSpaceLabel.Caption;
WizardForm.PageNameLabel.Caption:= SetupMessage(msgWizardSelectDir)
WizardForm.PageDescriptionLabel.Caption:= WizardForm.Hint
end;
end;
End;
The problem using this method is that only the content but not the actual page is changed. Message boxes and error messages are not affected. I wrote many lines of code to work around these problems but I encounter more and more problems...
Is there a better solution? I hope you can help me!
Edit: After experimenting a bit I came up with this:
procedure RedesignWizard;
var
Page: TWizardPage;
begin
Page := CreateCustomPage(wpWelcome, 'bla', 'bla');
WizardForm.ComponentsList.Parent := Page.Surface;
//Here I am changing the layout of the pages...
end;
procedure InitializeWizard;
begin
RedesignWizard;
end;
procedure CurPageChanged(CurPageID: Integer);
begin
if (CurPageID = Page.ID) then
begin
//perform your actions specific to the Custom page here.
end;
end;
This way the components list appears before the SelctDirPage and I do not have any more problems with those message boxes.
There is absolutely no way to safely swap the order of any of the builtin pages. (And usually, the only time people ask is when they are trying to replicate the flow of a different installation system. Relax and let it go; Inno works differently, embrace it instead of fighting it.)
Having said that, it is possible to give the appearance of swapping the pages, by recreating one or the other of them as a custom page. However by doing this you will forfeit all of the built-in functionality associated with that page -- eg. if you replace the components page then you cannot use the [Components] section or parameters, and if you replace the directory page then you cannot use {app} (not even in those places that use it implicitly, such as the UninstallFilesDir).
If you're willing to put in a lot of time and effort (especially testing), it can be done. But everything is worse off as a result -- so normally you're better off not doing so.
To add to what Miral said:
[Setup]
DisableDirPage=yes // disable the built-in page
[Code]
var
ApacheDirPage: TInputDirWizardPage;
ApacheDir: AnsiString;
procedure InitializeWizard;
begin
{ Create the custom wizard pages }
ApacheDirPage :=
CreateInputDirPage( wpSelectComponents, // display AFTER select Type/Components page
'Select Apache Directory',
'Select the Apache x.x Directory' + #13#10 + '(the one that contains the BIN folder)',
'Select the Apache directory, then click Next.',
False, '' );
ApacheDirPage.Add( '');
ApacheDirPage.Values[0] := csApacheLocation;
end;
I want to install the same application multiple times on the same system, for example for two user using two different web services (each one has their own).
In in my setup script I want to change the AppID and AppName based on input from the user (for example my default AppName="Service App" should be changed to AppName="Service App One" if the user has entered "One").
Above changes should be reflected in the "Select Start Menu Folder" page.
How can the Next click events for the "Select Start Menu Folder" and the "Select Destination Location" wizard pages be caught? This is required to validate the user input.
AppID can include {code...} constants (see the Inno Setup documentation), so you are free to add a custom wizard page to enter the additional string that is part of the AppID. I don't think it makes sense to do this for AppName, as according to the documentation it is used for display purposes in the wizard only.
You should insert your custom input page before the "Select Destination Location" page and try to use a {code...} constant for DefaultDirName too, using the value the user entered before.
See the CodeDlg.iss sample script for adding wizard pages and the NextButtonClick handler.
It's not a conplete answer to your question, but I thought I'd show it anyway. If you are into scripts you can maybe take it as a starting point.
In my scripts I want the copyright year (AppCopyright) to reflect the current year (when the script is build).
I use the following code:
AppCopyright=2003-{code:TodayAsYYYY} © E.De.L.Com bvba
Notice the {code:FunctionName}
In the [code] section at the end of the script I have the following routine:
function TodayAsYYYY(param:string) : string;
begin
Result := GetDateTimeString('yyyy', #0, #0);
end;
function TodayAsYYYYMMDD(param:string) : string;
begin
Result := GetDateTimeString('yyyymmdd', #0, #0);
end;
As I said, it's not a complete answer. But I use InnoSetup maybe 1, 2 weeks a year, so I can't help you any more. Hope it helps, anyway.
Hi thanks for replying after some struggle I found answers to my own question and then realised maybe I was not asking the question correctly.
The output required was having two separate installed application with their own uninstaller under the start menu and thought Changing Appid and Appname will do the trick.
Here's what I did
#define MyAppName "My Application"
[Setup]
DefaultDirName={pf}\Application\MyApp
DefaultGroupName={#MyAppName}
above two required editing which was possible in the custom pages using following
WizardForm.DirEdit.Text := 'for DefaultDirName' (Select Destination Location")
WizardForm.GroupEdit.Text:= 'DefaultGroupName'
WizardGroupValue is used for reading values of "Select Start Menu"
for accessing the next event on in built wizard I used the following
//Validate Select Start Menu and Destination values
function NextButtonClick(CurPageID: Integer): Boolean;
var
ResultCode: Integer;
begin
case CurPageID of
wpSelectDir:
begin
//Do validation
end;
wpSelectProgramGroup:
begin
//Do validation
end;
end;
Result := True;
end;