Inno Setup: Run uninstall script only once - inno-setup

I am using Inno Setup for our WinDRBD driver, which is a port of Linbit's DRBD driver from Linux to Windows (https://github.com/LINBIT/windrbd). We
are using Inno-setup for install/uninstall and it works very well.
One thing I noticed is that if the user installs the same version twice (or upgrades to a newer version, the script in the UninstallRun section is run multiple times (once for each install) later when the user chooses to uninstall the program. Is there a way to make it only once, even if the user installed several upgrades?
What I am currently using is:
[UninstallRun]
Filename: "C:\Windows\sysnative\cmd.exe"; Parameters: "/c uninstall-windrbd.cmd"; \
WorkingDir: "{app}"; Flags: runascurrentuser waituntilterminated shellexec
(note: the sysnative thing is because Inno Setup is 32-bit but the application is 64 bit, else INF install inside the script would do the wrong thing).
It is just a minor thing, we're running an INF file uninstall which
displays a message box when run the 2nd+ time. Maybe I am missing some flag?

Adding RunOnceId: "Uninstall" (where "Uninstall" is just a random tag, you can also use foobar) to the uninstall line does the trick.
So,
[UninstallRun]
Filename: "MyUninstallProgram.exe"; \
Flags: runascurrentuser waituntilterminated runhidden; \
RunOnceId: "Uninstall"
would be a way to have an uninstall program run only once, even if there are upgrades installed.

Related

Run ngen.exe after Inno install finishes but, before user can launch the app

I am able to run the following in the cmd console and it works. I can see the difference when the app is loading and when executing task within.
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\ngen.exe install "C:\Program Files (x86)\App Directroy\App.exe"
I am trying to have Inno perform the same when installing the app but, before the user has an opportunity to launch the app for the first time.
This is what I have tried so far with Inno:
[Run]
Filename: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\ngen.exe; Parameters: "install ""{app}\{#MyAppExeName}""";
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent"
What happens is that, when Inno finishes installing it starts the app and doesn't execute the ngen.
I am trying to find how to run the above code in the Inno script.
Am I placing the code in the correct section of the Inno script?
Any assistance is appreciated.
Regards,
I read what Martin Prikryl said about the hard-coded c:\windows... and looked into it and I found this article from Fabrizio Stellato and I was able to get it to work.
I changed this part:
[Run]
Filename: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\ngen.exe; Parameters: "install ""{app}\{#MyAppExeName}""";
to
[Run]
Filename: "{win}\Microsoft.NET\Framework64\v4.0.30319\ngen.exe"; Parameters: "install ""{app}\{#MyAppExeName}"" /nologo"; WorkingDir: "{app}"; Flags: runhidden; StatusMsg: "Optimizing..."; Check: IsWin64
I added the {win} to replace the hard coded c:\windows
I hid the cmd console with Flags: runhidden;
Show the status to the user with StatusMsg: "Optimizing...";
Fabrizio Stellato has a complete solution:
Part 1 InnoSetup, optimize your application with ngen
Part 2 InnoSetup, Optimize your .NET Application with ngen - Part II
Regards,

Inno setup UninstallRun and interactive process [duplicate]

I am using Inno Setup for our WinDRBD driver, which is a port of Linbit's DRBD driver from Linux to Windows (https://github.com/LINBIT/windrbd). We
are using Inno-setup for install/uninstall and it works very well.
One thing I noticed is that if the user installs the same version twice (or upgrades to a newer version, the script in the UninstallRun section is run multiple times (once for each install) later when the user chooses to uninstall the program. Is there a way to make it only once, even if the user installed several upgrades?
What I am currently using is:
[UninstallRun]
Filename: "C:\Windows\sysnative\cmd.exe"; Parameters: "/c uninstall-windrbd.cmd"; \
WorkingDir: "{app}"; Flags: runascurrentuser waituntilterminated shellexec
(note: the sysnative thing is because Inno Setup is 32-bit but the application is 64 bit, else INF install inside the script would do the wrong thing).
It is just a minor thing, we're running an INF file uninstall which
displays a message box when run the 2nd+ time. Maybe I am missing some flag?
Adding RunOnceId: "Uninstall" (where "Uninstall" is just a random tag, you can also use foobar) to the uninstall line does the trick.
So,
[UninstallRun]
Filename: "MyUninstallProgram.exe"; \
Flags: runascurrentuser waituntilterminated runhidden; \
RunOnceId: "Uninstall"
would be a way to have an uninstall program run only once, even if there are upgrades installed.

Inno Setup: How do I change the text used for the shortcut it makes?

I have a main application, MainProgram.exe and another application, Launcher.exe that simply does a little bit of work, launches the main application (MainProgram.exe) and shuts itself down. I don't want my users to know that the launcher is being run.
Using Inno setup I can install both programs into a folder, make a short cut to Launcher.exe and even start Launcher.exe when setup finishes.
But how do I tell Inno setup to set the text of the shortcut or menu item that the user sees to be MainProgram.exe and not Launcher.exe, even though the file actually being pointed to is Launcher.exe
(same for the text of the 'Uninstall ...' menu item).
I did check both of these SO questions but neither gave the answer.
Renaming/replacing ShortCut During Inno Setup Installation
Inno Setup Shortcut Issue
I guess I could just swap the filenames round but thay would be just too confusing!
Set this up using the [Icons] section in your install script. An example would be:
Name: "{group}\Main Program"; FileName: "{app}\Launcher.exe"; WorkingDir: "{app}"; IconFIleName: "{app}\MainProgram.exe"; Comment: "This is your launcher program in disguise".

msiexec run from innosetup displays help dialog

I've got the following code as part of my setup script:
[Files]
Source: "{#SetupDir}\IronPython-2.7.3.msi"; DestDir: "{app}\Resources"; Components: Centipede; Check: IronPythonNotInstalled
[Run]
Filename: "msiexec.exe"; Parameters: "/I ""{app}\Resources\IronPython-2.7.3.msi"" /qb"; WorkingDir: "{app}\Resources"; Flags: shellexec; StatusMsg: "Installing IronPython"; Components: Centipede; Check: IronPythonNotInstalled
But every time I run the installer, I'm getting the help dialog, as when you run msiexec without any parameters. It's probably just a silly mistake, but I can't see what it is.
The file is getting copied correctly, and the msi is valid (running it from the command line works fine).
The issue here is slightly more complex than I thought: the setup I was running was an old copy of the code.
Due to my environment, I was compiling the installer, pushing it to a (local) web server, then downloading on the test machine, and then running it.
I tried replacing msiexec with a "dump args" tool, and noticed that it still called msiexec.
Testing checksums confirmed it: I was just repeatedly downloading the same version.
The solution here, is to prevent caching of the downloaded installer.

Disabling Message Box for Components from INNO Setup

I am trying to install components (KB932716) and also MS Feature Pack Two. I am trying to add these in a single package and build the installer using Inno Setup.
When I run the set up, components shows up a huge message box which we don't like to show during installation. I tried \SILENT and \VERYSILENT switches but no use.
Any help on how to disable this message box during installation.
Use /quiet switch for running the component (note the slash is not a backslash).
[Run]
Filename: {tmp}\WindowsServer2003-KB932716-v2-x86-ENU.exe; Parameters: /quiet; WorkingDir: {tmp}; Components: ....
When in doubt, ask the hotfix the command lines it supports:
WindowsServer2003-KB932716-v2-x86-ENU.exe /help
...
/help Displays this message
SETUP MODES
/quiet Quiet mode (no user interaction or display)
/passive Unattended mode (progress bar only)
...

Resources