How to Install an NSIS Executable Silently For All Users - command-line

I have an NSIS installer executable which I would like to install silently for all users. I know I can pass the /S argument to do a silent install. The problem is that the default option for the installer is to install only for the current user. How can I change this option from the command line:
installer.exe /S

NSIS itself just supports /S, /NCRC and /D=c:\override\default\installdir\, everything else is up the author.
If the custom page from your screenshot was created with MultiUser.nsh and the author defined MULTIUSER_INSTALLMODE_COMMANDLINE then you could use installer.exe /AllUsers /S, otherwise you have to ask the author of the installer if they are checking for a specific command line switch.
If it turns out there is no way to do it then you would have to look into UI automation...

It turns out that for this particular installer you can pass:
/ALLUSERS=1
ALLUSERS is a standard MSI property. I did not find any documentation for this property in NSIS, so it looks like the developers of this particular installer added this.

Related

How to run an installation in /silent mode with adjusted settings

My goal:
I want to create a CMD command that will installs a program with adjusted install settings.
If I execute my .exe install file without any parameters, I have to click myself through the installation but I am able to change the install settings, like in which folder the setup will install the program or change the status of a checkbox.
However, I want to run the installation in /silent mode, in which I don't know how to change the install settings.
So the question is:
Is there anyway to give the shell a correct installation settings and then execute the file in silent mode?
I need this because I have to run the installation on multiple computers so it would be very comfortable if I had a script that runs the installation with correct settings.
Someone please guide.
Community: I'll elaborate later, but first let us do the easiest way. You could try to search for your software on sites dedicated to setup information and how to deploy various third party software silently:
https://www.itninja.com/software
Similar, terser answer: Silent run installer (.exe) with parameters on Windows
1) Standard Packaging Formats: If the setup.exe wraps a standard packaging format such as an MSI file, then you generally need to find a way to extract the package inside and customize its silent installation using standardized customization mechanisms involving command lines and MSI transforms.
2) Proprietary Packaging Formats: If the setup.exe is a proprietary format you need to either repackage it in a standard format (MSI) using tools to do so, or you need to run the installer in silent mode. The latter can be unreliable, but is often done for small scale distribution.
Look and Feel: Experience can teach you what tool was used to make the setup.exe by looking at the dialogs at runtime. Sometimes you see a company name or a tool name embedded in them.
So in summary:
Extract standard package if possible.
Customize standard package.
Repackage.
Install silently using original setup.exe.
Let's briefly describe these different tasks:
Extraction of Files:
There is a forest of tools that can create setup.exe files, it is impossible to cover all of them. They might feature all kinds of different command line switches. A setup.exe can even be totally proprietary, meaning no deployment tool was used to make it at all. It might have been compiled using Visual Studio for example.
A description of tools that can be used (non-MSI, MSI, admin-tools, multi-platform, etc...).
Common tools such as Inno Setup seem to make extraction hard (unofficial unpacker, not tried by me, run by virustotal). Whereas NSIS seems to use regular archives that standard archive software such as 7-Zip can open.
I try the following command lines to see if I can do a file extract:
setup.exe /a (Installshield MSI)
setup.exe /stage_only (Installshield Suite)
setup.exe /x (Wise, Advanced Installer)
setup.exe /extract_all (Installshield Installscript)
dark.exe -x outputfolder Setup.exe (WiX Burn Bundles - requires WiX toolkit installed)
Additionally some general tricks exist:
Launch the setup.exe and look in the system's temp folder for extracted files.
Another trick is to use 7-Zip, WinRAR, WinZip or similar archive tools to see if they can read the setup.exe format.
Some claim success by opening the setup.exe in Visual Studio. Not a technique I use.
The general approach for finding switches is to open a command prompt and go setup.exe /? or setup.exe /help or similar.
Also check for vendor online information and sites such as https://www.itninja.com/software.
A sprawling answer on this topic: Extract MSI from EXE.
If you manage to extract (or the file format is viewable as an archive), you can look for PDF, HTML, TXT or CHM files with further deployment info. Samples: ReadMe.txt, LSD.pdf, Large Scale Deployment.pdf, User Guide.chm, Manual.chm etc...
MSI - Customize Standard Package:
So, if the extract works and you extract an MSI file, then you can customize its installation in detail using standardized mechanisms. Make sure to look for the files with deployment information mentioned above - PDFs, CHMs, TXTs, etc... They could feature sample command lines for you to use more or less directly.
And crucially you could have extracted runtimes and prerequisites that also need to be deployed (.NET framework, Crystal Reports, Visual C++ Runtime, etc...). These are all managed and controlled on corporate networks and are not to be deployed with your package, but by their standardized packages.
Standardized customization mechanisms are great for corporate deployment, but require some MSI knowledge:
How to make better use of MSI files - a comprehensive description of MSI installation customization: with some sample command lines and description of the process.
A simplified view of MSI installation customization.
Here you can see that some setup.exe files can be installed directly in silent mode by passing in a command line using the /v parameter. These are Installshield MSI setups.
You can also see how the features in the MSI can be set at the command line.
A couple of concrete samples (extracted from links above):
Command Line Customization
msiexec.exe /i myinstaller.msi ADDLOCAL="Program,Dictionaries" SERIALKEY="1234-1234" /qn
ADDLOCAL specifies what features from the MSI to install (see feature sample screenshot here). The uppercase values such as SERIALKEY are PUBLIC properties that can be set on the command line. These vary from setup to setup. Look for documentation from vendor, check the Property table and check the setup dialogs.
Transform
msiexec.exe /i myinstaller.msi TRANSFORMS="mytransform.mst" /qn
The transform approach sets all the values needed inside a little file that is applied at installation time. It is called the transform. It is a little database fragment which is merged with the original MSI database at runtime.
Repackaging:
One way to create an MSI package from older-style, legacy setup.exe installers, is to "capture" the changes done to the system by using an Application Repackaging Tool which monitors changes made to the system whilst a setup.exe is being run.
This task may look easy, but it isn't. In fact it is very hard to clean up the resulting captures so you don't create "loose cannon" MSI files that cause problems on desktops throughout your organization. Corporations have dedicated teams to do this job and excellent MSI files can result that cause no problems when installed silently.
This task is not for the causal user in my opinion. It requires investment in the technology, expertise and time. Besides the tools available are pricey.
Silent Installation:
Most setup.exe files will at least attempt to install silently, though there are no guarantees. It is entirely possible that the setup.exe is impossible to install silently. I have seen it many times. In these cases repackaging is necessary, but even repackaging can fail at times. This is when it is time to push back on the vendor and ask them to get a grip about deployment. In a corporate world the software should be kicked head-first out of the application estate - if things work as they should.
Here is an old site dealing with the overall issue of silent installation of various setup.exe files: http://unattended.sourceforge.net/installers.php.
Here is a piece on silent uninstall which also describes silent running in general: Uninstall and Install App on my Computer silently
The general approach for finding such switches is to go setup.exe /? like you did. Often you can get a setup to install silently by trying something like this:
Visit https://www.itninja.com/software to check for switches from the community.
As stated above look for PDF, HTML, TXT or CHM files with further deployment info. Samples: ReadMe.txt, LSD.pdf, Large Scale Deployment.pdf, User Guide.chm, Manual.chm, etc...
Common: setup.exe /S, setup.exe /Q, setup.exe /quiet, setup.exe /VERYSILENT /NORESTART or similar.
Old-style Installshield setups need to have a response file recorded and then you install on all systems using the recorded dialog responses.
See this document.
Setup.exe /s /f1”c:\temp\my-answer-file.iss” /f2”c:\temp\my-log-file.iss”
Installshield Suites and regular Installshield setup.exe (links to Installshield's own help pages for setup.exe files)
Old Wise setups: https://www.itninja.com/blog/view/wise-setup-exe-switches
Some Links:
Create MSI from extracted setup files
MSI Deployment Tools List
Extract MSI from EXE
https://www.itninja.com/software
Uninstall and Install App on my Computer silently
Combine exe and msi file in one installer
How can I use powershell to run through an installer?
How to Install an NSIS Executable Silently For All Users

Is it possible to add a custom script fragment to the unix install4j uninstaller?

I would like to add a custom script fragment to the unix uninstall script generated by install4j. This is possible for scripts available under the launchers tab. Is this also available for the uninstaller? I'm using install4j 6.0.4.
Yes you can.
If you want to run shell script you need before the uninstall file step (because your script will not longer will be on the filesystem).
If you want to run Java code you can do it after the files deletion:
Add in the Run script step add you Java code.
This omission will be fixed in install4j 7.0.7 where installer applications will have a "Custom script fragment" property.
Please contact support#ej-technologies.com to get a build where this is already implemented.

Install software using command prompt start command with target directory

I am trying to install software using command prompt using below command
start /wait /d "C:\abc" C:\Users\abc.exe /silent /norestart
I want to install software in c:\abc folder but it is installing in the software default directory. Is there any way to install it into the custom directory using the start command or are there any other alternatives to install the software on the target directory.
SHORT VERSION:
This may be the most "accessible" and "quick" explanation for your particular case: http://unattended.sourceforge.net/installers.php
If you are dealing with an MSI file, you should use the admin install feature to extract all the installation files first and then customize your install by setting public properties or utilizing a transform to configure the install. Details here: How to make better use of MSI files.
See the link towards the bottom to find a list of different parameters you can use for different types of setup.exe files.
DETAILS:
A setup.exe file can be "anything". It can be an old, legacy Installshield or Wise installer, a modern Windows Installer file (MSI) embedded in a setup.exe launcher, an Inno setup file (non MSI), an embedded Advanced Installer MSI setup, a compressed and self-extracting zip file, a unique and custom made installer (proprietary), or any number of other technologies, the list goes on and on and on - it is impossible to tell what tool or technology was used to create your setup.exe from the information supplied.
Just for reference, let's link to installsite.org's information on different setup technologies and available tools. Most likely your setup.exe is made using one of these tools:
Non-MSI installer tools: http://www.installsite.org/pages/en/tt_nonmsi.htm
Windows installer tools: http://www.installsite.org/pages/en/msi/authoring.htm
This may also be of help: Wix - How to run/install application without UI.
The point is, naturally, that every, different technology has its own way to enable silent installation and to customize installation parameters. So the first step for you is to determine what this file really is. Right click the file, select properties and check the details tab for any clues. Or just run the setup.exe interactively and see what the window title is (top window title bar). It will generally indicate what tool was used to create the setup.exe.
Rather than rewriting it all, and since it is a stackoverflow link (unlikely to be removed), I will just link to a similar answer on how to install setup.exe files silently: How can I use powershell to run through an installer?. See the "some links" section for links to documentation for various tools.

How can I use powershell to run through an installer?

I am trying to install a piece of software that when done manually has configuration options you can choose from when going through the process. I am trying to figure out a way to automate this using powershell but am stuck as to how I can set those configuration options. I believe I would need to run the start-process command on the installer .exe but I don't know where to go from there. Can I use the parameters on the start-process command to pass in the configurations I want?
UPDATE: Several links towards the bottom with information on how to handle installation, configuration and file extraction for setup.exe files.
UPDATE: See Windows Installer PowerShell Module on github.com (scroll down for description, use releases tab for download). I haven't really tested it much, but it is from Heath Stewart - Microsoft Senior Software Engineer (github).
I had a quick look for that installer, but didn't find it easily. Essentially the installer is either a Windows Installer database (MSI) or something else - generally a setup.exe of some kind. An MSI database can also be wrapped in a setup.exe.
You should be aware that for legacy style installers a common practice for large scale deployment is to capture the legacy install with an application repackager tool, and then compile an MSI file to use for installation (effectively converting an installer from an old format to modern MSI format). This is a specialist task requiring good understanding of Windows and setups. It is generally done in large corporations for very large software distributions. If you are in a large company there might be a team dedicated to packaging software like the one you mention. Maybe check with your management. If the setup is an MSI the same team can also modify that for you according to your specifications.
With regards to your installer EXE. Try to run setup.exe /a from the command line and see if you get an option to extract files to a "network install point" (administrative install). Then you are dealing with an MSI file wrapped in a setup.exe. If that doesn't work you can try setup.exe /x or setup.exe /extract as well.
Windows Installer has built-in features to allow you to customize the install via PUBLIC properties (uppercase) set at the command line or applied via a transform (Windows Installer's mechanism to apply substantial changes to the vendor file - it is a partial database that gets applied to the installation database from the vendor at runtime).
Non-MSI, legacy installer technologies generally have fewer reliable ways to customize the installation settings, and they tend to be rather ad hoc when they are there. In particular the silent running and uninstall may be features that are missing or poorly executed. These installs are generally all wrapped in EXE format, and there are many tools used to generate them - each with their own quirks and features.
In other words, it all depends on what the installer is implemented as. Give that setup.exe /a a go, and update your answer with new information for us (don't add too many comments - we will check back).
With regards to using PowerShell. I haven't used PowerShell for deployment so far to be perfectly honest. Here is a basic description of how to install using PowerShell: https://kevinmarquette.github.io/2016-10-21-powershell-installing-msi-files/
You can also invoke automation for MSI files from PowerShell, I don't think this is relevant for what you asked, but here is a quick link for modifying a transform file: http://www.itninja.com/question/ps-how-to-edit-a-mst-file.
The normal way to install MSI files is via Window's built-in msiexec.exe command line. The basic msiexec.exe command line to install software is:
msiexec.exe /I "C:\Your.msi" /QN /L*V "C:\msilog.log" TRANSFORMS="C:\1031.mst;C:\My.mst"
Quick Parameter Explanation:
/I = run install sequence
/QN = run completely silently
/L*V "C:\msilog.log" = verbose logging
TRANSFORMS="C:\1031.mst;C:\My.mst" = Apply transforms 1031.mst and My.mst (see below).
What is a transform? Explained here: How to make better use of MSI files.
Advanced Installer has a general page on msiexec.exe command lines. And here is Microsoft's msiexec.exe documentation on MSDN.
Some links:
Perhaps see Michael Urman's answer here: Programmatically extract contents of InstallShield setup.exe. This is for Installshield packaged EXE files only.
Installshield setup.exe commands (general reference with some sample command lines - towards the end of the document it looks like the command lines are not correct, but the first ones look ok. The later ones are pretty obscure anyway - just thought I'd let you know since I link to it). Here is the official Installshield help documentation.
Wise setup.exe commands - Wise is no longer available, but if the setup is older it can still be packaged with Wise.
Advanced Installer standard command line. For this tool setups can apparently be extracted with setup.exe /x or setup.exe /extract. See the link for full list.
There was also a "silent switch finder" tool used to find hidden switches in exe files (for deployment), but it failed a virustotal.com scan so I won't link to it. Maybe it is using something exotic, such as scanning a file's header at a bit level or something weird that is flagged as malware by mistake? Either way, not a tool I would use.
And finally: http://unattended.sourceforge.net/installers.php. This link isn't bad, it presents some of the tools above and a few others - and the most common switches used. Untested by me, but looks ok.
And there are other deployment tools that have their own way of packaging and delivering EXE files - it can be a jungle. I can provide a list of such tools with more links, but maybe that's just confusing. Please try what is provided above first.
Here is a generic answer that might be helpful as well: Extract MSI from EXE

Determine Inno-setup command line options

I have a program, mingw-get-inst-20111118.exe
I want to do a silent install with this.
I have been using mingw-get-inst-20111118.exe /silent with success, but now I want to customize the install, if possible. Is there a program that will analyze this installer and show the possible parameters?
Related links
unattended.sourceforge.net/InnoSetup_Switches_ExitCodes.html
unattended.msfn.org/unattended.xp/view/web/39
As the install is based on InnoSetup, the standard command line parameters available are documented at http://www.jrsoftware.org/ishelp/index.php?topic=setupcmdline.
Looking at the installer source, I don't see much in the way of configuration. You can pass the /DIR parameter to change the default install directory. I'm not sure what other configuration you'd want to do though.
It appears that the developers have not added a Components section to the source, making it impossible for a silent, custom installation.
Compare:
mingw.cvs.sourceforge.net/viewvc/mingw/mingw-get-inst/mingw-get-inst.iss
code.google.com/p/msysgit/source/browse/share/WinGit/install.iss