Customize or remove NSIS uninstaller prompt - nsis

Is there a way to customize (call a custom plugin) or even completely remove the NSIS uninstaller prompt Would you like to proceed with uninstall? by adding a directive or any other piece of magic to the NSIS script?
I have also tried passing either of the /q or /s to the uninstall.exe with no effect.

This is not a normal NSIS message, did you use a generator or template to create your script?
You should be able to find the MessageBox in your script source and remove it (Or set a default for silent mode)

Related

NSIS' uninstaller works very fast

I have no idea how to say it short for title, but
When I run uninstaller generated by NSIS in silent mode, it detaches from main process and do its work in the background.
This is good, but when installer run ExecWait uninstaller first, it finish instantly, but doesn't uninstall application actualy. As a result, installer tries to replace executable file that executed, but not closed by uninstaller yet. Any solution?
Ok, I got it.
The NSIS uninstaller copies itself to the temporary directory, runs the temporary uninstaller created and then exits. This is done so it will be able to delete itself.
You can disable this system using the following command line parameter:
ExecWait '"$INSTDIR\uninstall.exe" _?=$INSTDIR'
You will, of course, have to replace uninstall.exe with the name of your uninstaller.

setup.iss file is not generated

I have a installshiled project which generates setup.exe file. I'd like to enable silent install by generating proper setup.iss file. I ran the following command:
Setup.exe /r
which lunched the installer, but it never created the setup.iss file. I looked in C:\Windows as the documentation suggested, as well as some other locations (local directory, program files etc.)
Why isn't it created and how to fix?
Thanks,
Ok I found the problem, and a workaround:
The problem was that my msi project was a Basic MSI Project, as opposed to InstallScript and InstallScript MSI projects. This kind of project does not support reading a response file (aka setup.iss). However, there is a way to perform silent installation for the .msi / setup.exe file:
Setup.exe /s /v"/qn"
will do the trick.
All of this information can be found here
Another option is to explicitly state where you want the setup file generated, using the /f1 option:
Setup.exe /r /f1"C:\your\path\here\setup.iss"
Documentation on this can be found here, but here is a summary from that link:
Using the /f1 option enables you to specify where the response file is (or where it should be created) and what its name is, as in Setup.exe /s /f1"C:\Temp\Setup.iss". Specify an absolute path; using a relative path gives unpredictable results. The /f1 option is available both when creating a response file (with the /r option) and when using a response file (with the /s option)

Extended NSIS plugins directory

I am building a plugin for NSIS with VS 2010 and I would love to set up the project so that a test setup is automatically built from a simple NSI file.
All seems fine except I can't figure out how to make NSIS look for my plugin in my project's output folder instead of C:\Program Files (x86)\NSIS\Plugins\*.dll only.
Are there any commands I can put in my NSI script to make NSIS look for my freshly built plugin outside of "standard plugins folder"? It seems rather odd to have to copy my DLL each time I wanted to test it.
Any help is appreciated.
You can use !addplugindir directive, see nsis compile-time commands.
Use !addplugindir directive with defined symbol (/D on command line).
Symbol is "the path to your location of .dll file"
For VS 2010 is the best option to use Visual & Installer - free VS addin for developing NSIS installers directly in Visual Studio.
Set your symbol in Project properties:
Download here: www.unsigned-softworks.sk/visual-installer/
As others have mentioned, the !addplugindir directive in your NSI script file will do the trick, and you can define a variable to pass to that directive on the command line using /D.
As for the code to add to your NSI file, you need something like this:
!ifdef EXTRANSISPLUGINSFOLDER
!addplugindir "${EXTRANSISPLUGINSFOLDER}"
!endif
Then on the command line, you can call your NSI script like this:
makensis.exe /DEXTRANSISPLUGINSFOLDER=C:\somefolder\moreplugins\ YourInstallerScript.nsi
When defining the extra folder, you might find that having any spaces in the folder path causes problems, and using quotes around the path doesn't help. To work around this, try using the dir /x command in the Windows terminal to list the 8.3 DOS names for the folders with spaces in their name. This will help you build up a folder path that doesn't contain spaces. (eg C:\Program Files\ often becomes C:\PROGRA~1 when listed with dir /x from the root of C:)
May have missed the point here but could you not have used an XCOPY post build event to copy the output to the NSIS plugins directory?

cpack: how to associate program with file extension during install?

I'm creating a windows installer with CPack and NSIS. During the install process the user should be asked if he wants to associate my program with a file extension. At least if you do "open with..." on a file with the extension windows should be told that you can open it with my program. Does anybody know how to do this?
Go to your nsis installation folder on you system and have a look at makensis.nsi from the examples directory. It associates .nsi to makensisw.exe.
Good luck ;)
To create file associations using NSIS I would recommend using NSIS plugins mentioned by Andrei T: File Association and FileAssoc. To integrate them into CPack you need to include the script, call macro during install step, call other macro during uninstall step.
For example this is how I use "File Association" plugin:
# Including
set(CPACK_NSIS_EXTRA_PREINSTALL_COMMANDS
"!include \\\"${path_to_plugins}\\\\fileassoc.nsh\\\"")
# Create association
set(CPACK_NSIS_EXTRA_INSTALL_COMMANDS
"\\\${RegisterExtension} '$INSTDIR\\\\myprogram.exe' '.myext' 'my_program_key'")
# my_program_key can be any string that gives some hint what this file type is about. And should not contain strings
# Remove association
set(CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS
"\\\${UnRegisterExtension} '.myext' 'my_program_key'")
In this implementation it is not an optional step.
Please note the double escape. It is required because CPack creates intermediate file with those strings and if you escape only once there will be a syntax error.
Also note that all CMake paths should use back slashes. I convert them with:
get_filename_component(path_to_plugins"${path_to_plugins}" ABSOLUTE)
file(TO_NATIVE_PATH "${path_to_plugins}" path_to_plugins)
string(REPLACE "\\" "\\\\" path_to_plugins"${path_to_plugins}")

Is it possible to package an exe into an NSIS generated installer which runs first?

Is it possible to generate an NSIS installer (using a .nsi) which packages an exe (let's say foobar.exe) which is then run before the installer actually installs the program as normal? I assume it'd have to extract the exe to a temp dir before running it, which is fine. It must be run before the main install however.
Initpluginsdir
File "/oname=$pluginsdir\myapp.exe" "c:\build\myapp.exe"
ExecWait '"$pluginsdir\myapp.exe"'
Delete "$pluginsdir\myapp.exe" ;delete is optional, $pluginsdir is auto-deleted when installer quits
Put before other code in your first section or in .onInit (Depending on what myapp.exe does etc)

Resources