Prompting to install DirectX in an Inno installer - inno-setup

I am creating and installer for a game using Inno setup and I want to prompt the user and ask them if they want to install DirectX9 (I already have the full installation directx files in a subfolder) and then to install it for them if they say yes or no... I am not sure how to do this and have limited programming knowledge. Please help!

Use this code to show message box with question and Yes/No buttons:
// Ask the user a Yes/No question
if MsgBox('Are you sure?', mbConfirmation, MB_YESNO) = IDYES then
begin
// User clicked Yes
// Install the DirectX now... (see below)
end;
And this code to execute (launch) DXSETUP.exe
var
ResultCode: Integer;
// Launch DXSETUP and wait for it to terminate
Exec('DXSETUP.exe', '', '', SW_SHOW, ewWaitUntilTerminated, ResultCode);
I think you need to pack your DirectX files into your installer and extract it to {tmp} directory - or you may run it from CD/DVD (as in example).
See this question for advanced DXSETUP: How to install DirectX redistributable from Inno-setup?
If you need to detect DX version check this: http://www.vincenzo.net/isxkb/index.php?title=DirectX_-_How_to_detect_DirectX_version

You can use a [Tasks] entry to display a checkbox on one of the wizard pages prompting them whether to install/upgrade DX or not (and you can choose whether you want this to be ticked or unticked by default).
For the actual installation, the simplest option is to use a [Run] entry with Tasks: parameter linked to the [Tasks] entry you created; but bear in mind that this will install after your game and you won't be able to catch any errors it might raise. (This is usually not a problem for this sort of thing though.)
The other option is to use the PrepareToInstall event function in [Code]; for this you will need to use ExtractTemporaryFile and Exec. This will install it before your game, and lets you check the exit code to handle errors and reboot requests if need be. See the example script included with Inno for more details, but this is probably more complex than you need for a DX install.
You will also need to decide whether you want to bundle the web-installer or the full-installer for DX. The former is smaller but will require Internet access at install time; the latter will make your installer larger but will not require Internet access. If you are installing from a DVD then the latter is the best option (and you could run it directly from {src} instead of bundling it in [Files] in that case).

Related

How to force using /NORESTART and other flags without using command line

Is it possible to force using some flags like /NORESTART, /NOCLOSEAPPLICATIONS or /VERYSILENT in Inno Setup without using command line?
There's no generic solution to your question that would cover all switches. Implementing a functionality of each switch needs an ad-hoc implementation (and hence requires a separate question).
Actually, you can use .inf file instead of the command-line. But I assume that this not what you ask for.
/VERYSILENT is answered here already:
Run installation using Inno Setup silently without any Next button or Install button.
I'm answering the /NORESTART switch here.
You can hide Yes/No restart radio buttons (and select the No). And update the screen text accordingly.
See Avoid restart prompt in Inno Setup.
Additional handling is needed if you have postinstall entries in the [Run] section.

Bring Inno Setup installer to the foreground

How to bring the installer to the foreground at every progress page? (Assuming that the person installing the program decides to do other things with the computer in the meantime).
I am using this code to install DirectX and redist:
Inno Setup - Avoid displaying filenames of sub-installers
(look only the part that includes this ProgressPage := CreateOutputProgressPage).
Do not even try this. That ruins user experience.
And Windows actually prevents you from doing that anyway.
If you need to bring user attention to your installer/application, flash its taskbar button.

Inno Setup: Ask for reboot after uninstall

I would like to ask the user to reboot the system, after the application has been uninstalled.
By using AlwaysRestart=yes the user gets only asked after the installation, but the prompt doesn't appear afterwards.
I am using Inno Setup to solve this.
Thank you.
Use UninstallNeedRestart event function:
function UninstallNeedRestart(): Boolean;
begin
Result := True;
end;
It makes uninstaller ask for reboot at the end.
Note that you cannot combine this with the AlwaysRestart directive.

Change Inno Setup messages from Pascal code

I need to change ConfirmUninstall, UninstalledMost (just in case), and UninstalledAll specifically from script to set a condition. Something like this:
if FileExists(ExpandConstant('{app}\Slash.exe')) then
SetupMessage(msgConfirmUninstall) := FmtMessage(SetupMessage(msgConfirmUninstall), ['Dagon Slasher'])
else if FileExists(ExpandConstant('{app}\Frank.exe')) then
SetupMessage(msgConfirmUninstall) := FmtMessage(SetupMessage(msgConfirmUninstall), ['Dagon Frankenstein'])
else
SetupMessage(msgConfirmUninstall) := FmtMessage(SetupMessage(msgConfirmUninstall), ['Dagon Video Tools']);
But this doesn't work. These messages are used in MsgBoxes, so I can't think of any other way. Running in silent mode is not really suitable for me, since setup will run uninstall if the programs (or one of them) has already been installed, so I don't want the user to accidentally uninstall the program by running the setup.
You cannot change these easily, see:
Replace or customize modal uninstallation windows in Inno Setup
Regarding the silent uninstall solution: I do not understand your problem with "setup will run uninstall if the programs (or one of them) has already been installed".
I assume you run the uninstaller only after the user confirms (s)he wants to install the new version, so you actually want to run the uninstaller silently, right?
And anyway, there's nothing that prevents you from running the uninstaller non-silently from your installer, even if the entry in "Add/Remove programs" refers to "silent" installation.
You can use generic messages that covers all setup types:
[Messages]
ConfirmUninstall=Are you sure you want to completely remove this game?
As your uninstall messages depend on a type of the installed application, you can modify the installer to:
Create custom "type" page (like a menu) as the very first one.
Once the user selects the "type", restart the installer with a custom switch (e.g. /APPTYPE=slasher) and exit.
Once the installer is (re-)run with the /APPTYPE, you know from the beginning, what component/type you are installing and hence you can set the AppName accordingly (using a scripted constant).
Of course, you skip the custom "type" page.
This is actually not difficult to implement. The only drawback is that the setup window is "recreated" after the user selects the "type".
I've sketched this solution already in my answer to Inno Setup Change AppName based on component(s) selected.

Inno setup a simple update

Is it possible to use same Inno Setup installer for installing new or updating/upgrading application. For example If the application is already installed the installer will check current version against newly availible. If it is true then I would like the installation procedure to be silent, meaning showing only the progress of update and not all availible installation features (e.g. folder location e.t.c). Thanks.
=======
The solution to the problem was :
Passing the parameters /SILENT/SUPPRESSMSGBOXES
taken from
http://www.jrsoftware.org/ishelp/index.php?topic=setupcmdline
For the standard screens, simply add the following to your [Setup] section:
[Setup]
DisableDirPage=auto
DisableProgramGroupPage=auto
This will automatically hide the directory and group selection pages on subsequent installs (using the previously selected values, by default, unless you've used other settings that disable that behaviour).
Components and Tasks will still display, but that's usually a good thing as it allows the user to add additional components or re-perform certain tasks. (Note that you can use the checkedonce flag on [Tasks] entries to only tick them by default during the initial install, but allow the user to re-tick them manually if required.)
It's possible to skip even more pages through use of [Code], but this is rarely necessary.
Another option is that if the installer is being run from your application itself (eg. as part of a "Check for new versions" task) you can use the /SILENT command line parameter to hide the normal interactive UI.

Resources