In Inno Setup, how to rollback a "verysilent" installation? - inno-setup

I have created an installer using Inno Setup. The installer uses a packaged-in DLL to check availability of a specific device on the target machine. If the device is found, the installation is allowed to finish, otherwise the installation is rolled-back (rollback is done using below lines in script):
if <DeviceNotFound> then
begin
CancelWithoutPrompt := true;
WizardForm.Close;
end;
I have checked that the above check and rollback logic works fine if the setup is run with /silent cmd line param. However, when I use /silent param, the setup displays the Installation progress wizard form.
Also, I found that if I run the above setup in /verysilent mode, then the "DeviceNotFound" check logic works fine but the rollback logic doesn't work and it seems as if rollback logic doesn't get executed at all. Instead of performing rollback, the installer successfully installs.
Now, I have a requirement to run the setup silently so that no window is displayed but it must install or rollback based on device check. Therefore, I have the below queries:
Can I rollback the installer when it is running in /verysilent mode? If so, please advise how it may be achieved. I can detect verysilent install mode as shown in question:
How to detect whether the setup runs in very silent mode?
Alternatively, can I Hide/Minimize the Installation progress window when it is running in /silent mode? If so, please advise how it may be achieved.
Please help me with my above queries.
Sorry to be so descriptive but I tried to explain my problem and queries!
EDIT
I am not doing the above mentioned check in InitializeSetup(). I am doing the check from a function invoked by AfterInstall directive from [Files] section. I have a limitation that I cannot do it from InitializeSetup() as the packaged-in DLL is not extracted till [Files] section completes. I also need to run the installer in Windows PE (Preinstallation Environment), hence I cannot use ExtractTemporaryFile() function to forcefully extract the DLL because the {tmp} path is not valid in that environment. That leaves me with only one option is to check after [Files] section is done. Please advise!

Your constraint on not using ExtractTemporaryFile does not make sense.
The Inno Setup installer always creates a temporary folder for the installation.
2015-07-31 09:02:07.458 Created temporary directory: C:\Users\martin\AppData\Local\Temp\is-1CN29.tmp
If it is not possible to create the folder, the installation fails.
The Inno Setup tries to create the temporary folder in these locations:
%TMP%
%TEMP%
%USERPROFILE%
Windows installation folder (C:\Windows)
At least the last path has to exist even in the "Windows PE".
So I do not think, there's anything preventing you from using the ExtractTemporaryFile function.

Related

Changing restart message on Inno Setup Prepare To Install page

I am building an installer in Inno Setup v6.2.1 with prerequisites, which include .NET, runtimes, and KB fixes (Windows 7 SP1). The goal is to do potentially several reboots depending on if the machine is missing KBs or .NET etc.
I am able to achieve what I want so far using PrepareToInstall and can change the text by returning the appropriate string. No problems... however I can't find a way of changing the.
Setup must restart your computer. After restarting your computer, run Setup again to complete the installation of xxxxx
Because I am creating a runonce entry, the installer will automatically run after reboot (which it does). The text "run Setup again" is not relevant in my situation and I want to change the text to say that the installer will continue once you restart.
I have tried to find where to change this text but with no success. I assume that PreparingMemo might be the candidate but no luck or not sure how to use it. Any help would be appreciated.
See Handling and customizing errors and messages in Inno Setup.
This particular message is defined by the PrepareToInstallNeedsRestart message.
You can change it in the [Messages] section:
[Messages]
PrepareToInstallNeedsRestart=Setup must restart your computer. After restarting your computer, the Setup will continue to complete the installation of [name].%n%nWould you like to restart now?
If you need to change the message text dynamically, assign WizardForm.PreparingLabel.Caption. E.g. from CurPageChanged(wpPreparing) event.

Inno Setup: Can you add a NOT case to CloseApplicationsFilter?

I have an inno setup installer script that already handles closing one of the applications in use (that runs in the system tray) as part of ssInstall using old V5 ANSI version. With V6 version the restart manager support wants warn that it's open and will close it.
I found the CloseApplicationsFilter value that can be used in [setup] but I want the inverse case, I want to tell it which NOT to include (exclude just one .exe) otherwise handle all the other files as normal.
Is that possible?
Thanks.

Inno Setup: Calling uninstaller while in setup - is that a proper way to rollback?

I've got a task to sort out a problem with our product installer and eventually came to a dead end with no ideas.
The installation process goes like:
Install files
Configure some services in [Run] section
Run our custom product configurator
If step 3 is successful (configurator returned good exit code) then start those services
else rollback installation
So the issue was something Shroedinger's - on SOME machines there were unexpected reboot after cancelling install in configurator, without any questions. Of course that annoyed users.
I couldn't figure out the criteria by which the machine decided to reboot, but I stumbled onto this thing:
In [Run] section
Filename: "stub.exe"; Flags: runhidden skipifdoesntexist; BeforeInstall: ConfigureService
Then in [Code], ConfigureService calls for InstallationAbort proc if configurator returned bad exit code.
Next, in InstallationAbort:
Exec(ExpandConstant('{uninstallexe}'), '/VERYSILENT /noinstancecheck', '', SW_HIDE,
ewWaitUntilTerminated, ErrorCode);
So the author calls for uninstaller WHILE IN THE INSTALLER.
Using logs I determined, that installation program doesn't end after uninstaller completes work! It's moving to the next step (installation finished)! After that I can see in log
Restart needed? Yes
Note: system never reboots if configurator is not cancelled, i.e installation finishes the right way.
So what I tried:
Adding /NORESTART to uninstaller Exec call. Doesn't help. I think that's because it's installer, who decides to make a restart.
Adding WizardForm.CancelButton.OnClick(WizardForm.CancelButton); and some other calls to exit setup after call to uninstaller. Doesn't help.
Overriding NeedRestart function to return false in case of cancellation
As I tried to understand, author calls uninstaller because of need to delete installed services (i.e. call them in UninstallRun with special parameters)
So, my main question: Is that a normal practice to call uninstaller from code called from [Run] section, to undo changes made in [Run]?
Is that a normal practice to call uninstaller from code called from [Run] section, to undo changes made in [Run]?
In general, it's not a common practice. One should not abort installation in Run section. Inno Setup is not designed to handle that.
But if you need to, there's no other way. The code you have is most probably based on this:
How to force Inno Setup setup to fail when Run command fails?
But that does not imply that the installer should require reboot. There's some conflict between the installer and uninstaller.

Inno Setup:Automatic rollback process

As part of installation, sometimes i see few erors during a file replacement etc, so then inno setup gives a message like "abort/retry/ignore" if the user chooses abort inno setup rollbacks the installation.
So i want to know 2 things here
1)I wanted to know from my installer, whether a roll back is invoked or not? can inno setup give any acknowledgeent for automatic rollback happend or not?
2)what are the steps of rollback, what all does it do in that? a detailed explanation would be very helpful...

INNO: Disallow "Ignore" when file is in use

I am using Inno Setup for the installer for my windows application. If a user has the application when the installer is run (eg. for an update), the installer will stop when it is unable to replace a file in use, and it allows the user to select whether to Abort, Ignore, or Retry.
I would like it to only allow Abort or Retry and remove the option to Ignore. Does anyone know how this can be done?
Or if this can't be done, how can I make the installer abort if the application is running?
The easy way to detect whether the application is running requires co-operation from the application, so it's best to work this out before you ship your first version. Use Inno Setup's AppMutex setting. There is an example in the Inno Setup knowledge base for setting up a mutex visible in multiple sessions. There is more about AppMutex in Inno Setup's help file.

Resources