Inno Setup: Replace "Setup/Uninstall" string in UAC prompt for uninstaller - inno-setup

I am digitally signing my setup packages created with Inno Setup. When the user launches the uninstaller, the following UAC prompt appears in the very beginning:
I could replace the text in the red box for the setup package with the AppName directive, but I couldn't do this for the uninstaller.
How to replace that default "Setup/Uninstall" string with a custom string in uninstaller?

When you set AppName, it ends up as "File description" in the installer's binary resource block (among other places). That's what I believe is what UAC prompt displays.
For uninstaller binary the "File description" is hard-coded to "Setup/Uninstall". You cannot change it (at least not without some hacks).
But afaik, the UAC prompt actually prefers displaying description from the digital signature of the binary. As your binary is signed, just make sure you specify the description, when signing. If you are using the Microsoft signtool, use its sign command's /d switch.
In Inno Setup, the sign command is shared between installer and uninstaller. But they are still signed separately. So it's still possible to have different description for them. Just create a sign script (a plain Windows batch file will do), that checks what is being signed, chooses appropriate description and calls the signtool. And use your sign script in Inno Setup, instead of using signtool directly.
A trivial example:
#echo off
set FILENAME=%~n1
if "%FILENAME%" == "uninst.e32" (
set DESC=My Program Uninstaller
) else (
set DESC=My Program Installer
)
signtool sign ... /d "%DESC%" "%1"
For a proof of this concept, see Microsoft SmartScreen - suspended using Inno Setup installer?
Note that the sign command is not executed with your script path as a working directory. So you will have to use a full path (or alter PATH). When defining the path in the iss script, use SourcePath preprocessor variable. Like this:
SignTool=mysignscript {#SourcePath}\sign.bat $f
With some smart (but unreadable) syntax, it should be possible to achieve the same with one-liner directly in the .iss script. I'd recommend powershell instead of cmd for this though.
Ntb, as the above linked question shows, the sign script is exactly the place which you can use to hack the uninstaller's "File description", if you want to modify it too.

Related

Add user defined command line parameters to /? window

With Inno Setup it is possible to add user defined command line parameters. When I use the /?, /HELP command the user defined parameters are not listed there. How can I add my commands with a description to the /?, /HELP window?
Inno Setup 6.0 supports HelpTextNote message, whose contents will be inserted into the /HELP box.
In older versions:
You cannot.
The help text is hard-coded and not customizable in any way. It's not even localized.
It is even displayed before any Pascal Script code (InitializeSetup) is executed, so there's even no room to install some fancy hook to modify the message box on runtime.
See the ShowHelp function in the SetupLdr.dpr.
All you can do is to implement a custom switch (e.g. /usage) and handle it in the InitializeSetup event function.
Or, of course, you can modify Inno Setup source code and re-compile it. It's open source.
A related question: Is it possible to accept custom command line parameters with Inno Setup

Can NSIS's $TEMP value be over-ridden?

I have a customer using Host Intrusion Protection and has set every User's temp folder not to allow execution (C:\users\\AppData\Local\Temp). NSIS extracts all plugin dlls and its own dlls into a folder below %TEMP%. The problem is nothing is allow to execute from temp so the entire install fails. What I need to know is how to tell NSIS to use a different folder. The only work around I can find is to edit the TEMP and TMP values under the registry key HCU\Environment from "%USERPROFILE%\AppData\Local\Temp" to something like C:\NSISTEMP. However even though this works changing the registry and then putting it back is not really an option. I also cannot just redirect InitPluginDir as that only effects plug-ins and not the rest of what NSIS extracts (icons xml files etc...). Any ideas?s
You can set %TMP% in a terminal/console window before running the installer, there is no need to edit the registry.
In NSIS v3+ you can use UnsafeStrCpy:
Function .onInit
UnsafeStrCpy $Temp "c:\foo\bar"
CreateDirectory "$Temp"
FunctionEnd
The real problem is the security "solution", why would preventing execution from %Temp% but not from other directories really provide any protection after the bad guys find out about this restriction?
If the installer is started with the special _?=$InstDir parameter then it is not copied to %Temp%.
Try this (look for more info in documentation) maybe it is safer than overriding $Temp folder and so on.

Default Values to Inno Setup install

I have a group at work asking if there is a way to pass in values, either via command line or an ini value, that will "fill in" values that are normally provided by the user during install. For example, if I have a drop down that the user can select they're installing the client, server, or both, they want a way to automate this so the user doesn't have to select anything.
Basically, they want to automate running the installer without actually showing the wizard panels and populating user values based on command line args or an ini file.
I know you can use ini files, but I don't think they're used for this reason. And I don't see any way that command args would be used.
Is there a way native to Inno Setup to do this?
Thanks!
One way to set all the standard settings at once is to use an INF file via the /LOADINF parameter.
It is also possible to extend this to custom page settings if you wish (with cooperation by the setup author).
There are many command line parameters already included in Inno which you can use: http://www.jrsoftware.org/ishelp/index.php?topic=setupcmdline
With them you can set task, directory, group, components, password etc etc.
If you need something special you can use your own command line parameters.
Use GetCmdTail() function to get cmd line parameters for setup or uninstaller.
As this is common question there are already some advanced parsers and methods like this one:
Is it possible to accept custom command line parameters with Inno Setup
I suggest you to use /SILENT parameter for not showing the setup forms together with e.g. /TASKS, /DIR and /COMPONENTS and some custom parameter.

how to host an exe with a dynamic commandline parameter

I have an installer exe which takes a channel_id param as a command line parameter and uses it.
The channel_id may be different for different downloads and installs.
I want to host my installer exe on web in such a way that when it's downloaded and executed (by double clicking) the channel_id is passed to it in someway ,which should be equivalent to running the installer exe in cmd with channel_id as below.
cmd> myinstaller.exe channel_id.
How is it possible to do so ?
You can append data to the end of the .exe file.
You can include your param in the name of the file. For example, instead of setup.exe, call it setup_XXXX.exe. Then from NSIS you can read and parse $EXEPATH and extract your param from the filename.
Probably not the most reliable way to do this (if there is any), but you could probably check for the Zone.Identifier. I'm not aware of a way to this natively in NSIS, but you might be able to achieve by parsing the result through the commandline.
Try
nsExec::ExecToLog 'more < "$EXEPATH:Zone.Identifier"'
or
nsExec::ExecToLog 'dir /r "$EXEPATH"'
I've also found several Powershell (and VisualBasic) scripts that allow interacting with Alternate Data Streams, but personally I'm not a big fan of using third party scripting languages.

how to display please wait dialog during EXEC() function

how to display please wait dialog while EXEC() runs another application silently.
You can use a ProgressOutputWizardPage, which works just fine for me, which isn't exactly complicated. You can refer to the CodeDlg.iss example.
Do you really need it to be a message box? As you might know, you can run an external *.exe during setup, and have a custom status message shown meanwhile. (The status message will be on the usual progress label during installation.)
I have a setup.exe that installs product A. This setup.exe contains a setup2.exe file, used to setup product B. setup.exe copies setup2.exe to the Program Files folder during the installation of product A. When all files have been copied, setup.exe then starts setup2.exe in the background. To accomplish this, i have done
[Run]
Filename: "{app}\setup2.exe"; StatusMSG: "Installing Product 2..."; Parameters: "/VERYSILENT /SUPPRESSMSGBOXES"
in setup.iss (that compiles to setup.exe). setup2.exe is also an Inno Setup installer, so the parameters "/VERYSILENT /SUPPRESSMSGBOXES" will make the installation of product 2 silent. During this setup, setup.exe will show the message "Installing Product 2...".
If you really need a message box to popup with the status message, you'll have to resort to Pascal scripting.

Resources