2

I'm tasked with reducing a 50-page installation manual to "much less"; a bunch of applications need to be installed in a specefic order, with specific options, and so on. Can I use any of the popular installers (WiX, NSIS, Inno Setup) to automate this process, or do I need to use Powershell?

I've read about what these installers can do, and as far as I can see they're designed to install one application to one computer -- I haven't seen that or even if they can be used to control other installers in a very detailed fashion -- "use this, this, and this option on this wizard page, but not that one on the next wizard page, and install to this path, then enter these details (users, whatever)".

Am I wildly over-understanding what these tools can do? Given that I need to do this, what's the best way to go about it?

Update 2: I learn that installers do offer silent install by way of a config file. Neat! I'm currently looking at NSIS (spawning Powershell scripts and other installers) as the option that's easiest to just start & go with. I like that I don't need a custom IDE for it. But I'm also wondering wether NSIS is (soon) obsolete, in a Windows 7&10 world?

KlaymenDK
  • 714
  • 9
  • 31
  • 1
    For Inno Setup, see [Inno Setup: Install other installer and run it before continuing my install](http://stackoverflow.com/q/19589309/850848) or [Inno Setup launch executable (to install drivers) during installation](http://stackoverflow.com/q/11416536/850848) or [How can I install .NET framework as a prerequisite using InnoSetup?](http://stackoverflow.com/q/20752882/850848) or [Innosetup installing prerequisites](http://stackoverflow.com/q/12823599/850848). – Martin Prikryl Nov 12 '15 at 17:53

4 Answers4

2

You should look at WiX with a custom bootstrapper UI. That can be used to install any number of setups in whatever order you want. The tricky question is whether all those setups need to show their own UIs, one after the other. If they can all be installed silently with command line paramaters, then your WiX bootstrapper could show your UI to collect all the options, and then install each of the setups silently while you show progress for the entire operation. You could also get a single entry for the entire package in Programs&Features. So something like WiX could do it, but the UI requirements could make it awkward.

PhilDW
  • 20,260
  • 1
  • 18
  • 28
1

PowerShell CAN do it, but it's through invoking COM objects and sending keys to the window, so it's not the BEST way to do it. I'm going to repost something I posted yesterday to a similar question about using PowerShell to uninstall some unwanted software.

QFT:

PowerShell isn't going to interact with the prompts... you can't just tell it to click "Next" in an executable because it can't see it.

You can send keys to it though. You're really just using COM objects.

So, first, get your process ID by setting a variable that contains an array, the data for which is defined by the name of your process. Let's say your process is called, "Uninstall" and the process is ALREADY RUNNING:

$a = Get-Process | ?{$_.Name -eq "Uninstall"}

Start the COM:

$wshell = New-Object -ComObject wscript.shell;

Bring the uninstallation program with this process ID to the front so we can send it keystrokes:

$wshell.AppActivate($a.id)

Give it a few seconds to bring that window forward. I chose 5, but if your machine isn't stressed, 2 is probably enough:

Start-Sleep 5

Now start telling it what keys you want to send. The syntax here is this: whatever is in the () is what will be sent. The position in the single-quote is the keystroke to send, after the comma is how long you want it to wait before proceeding. Assuming the first screen is "Next" you can send your first command by telling PowerShell to send the ENTER key and wait 5 seconds:

$wshell.SendKeys('~',5)

The wait function is optional, but for your purposes, you're definitely going to want it. (If you don't want it $wshell.SendKeys('~') would send the ENTER key and immediately move to the next command.)

Walk through the uninstallation yourself manually, using all keystrokes, and for any keystroke you send, pay attention to how long it takes before the next part of uninstallation is loaded, and wait longer than that with your script (e.g. if it processes your ENTER key instantaneously, I'd have it wait 3 or 5 seconds before it sends the next command. If it takes 5 seconds to load, I'd tell it to wait 10 seconds before sending the next command).

Letters are letters, and numbers are numbers. Most non-commands are just assigned to their keys (meaning if you want to type "K" your command would just be $wshell.SendKeys('K')) You can get the rundown for the specific keys here: https://msdn.microsoft.com/en-us/library/office/aa202943(v=office.10).aspx.

/QFT

You may want to look into Auto-It, but that's based on pixel, last I checked, so if you run it on machines with different screen resolution, it can cause problems.

Community
  • 1
  • 1
Nate
  • 802
  • 1
  • 8
  • 28
  • FYI, this is from http://stackoverflow.com/questions/33650913/powershell-uninstall-software-that-has-prompts-for-user-input/33657270#33657270 and, as I said in the comment on the other thread, do NOT let anyone touch the machine while you're running this script, if you use it! – Nate Nov 12 '15 at 17:54
  • 2
    Autoit is definitely a better solution. While you can hook a window by screen position, you can also hook it by handle so it is not necessarily linked to screen resolution. – EBGreen Nov 12 '15 at 18:59
  • I up-voted you because I agree with your agreeing with what I'm saying. :) – Nate Nov 12 '15 at 19:23
  • Thank you for you thorough answer (even if it's reuse, that doesn't diminish its value). The "do not let anyone touch" might be a challenge, as I won't be anywhere near it myself. But, there should be room on-screen for a prominent "gefingerpoken" banner. – KlaymenDK Nov 12 '15 at 20:48
  • When you run it, you could just cut the keyboard and mouse cables. :P – Nate Nov 12 '15 at 21:03
1

How you approach this really depends on if these other installers supports silent mode and/or answer files. This page list the options for some of the popular installers.

If they do and you decide to use NSIS then you would just do something like this:

Name "BundleInstaller"
OutFile "bundlesetup.exe"
RequestExecutionLevel Admin

Page Components # Comment out this if you don't want the user to have a choice
Page InstFiles

Section -Init
InitPluginsDir # $PluginsDir directory is deleted when the installer quits
SetOutPath "$PluginsDir"
SectionEnd

Section "Foo v1.2.3"
DetailPrint "Installing Foo"
File "FooSetup.exe"
ExecWait '"$PluginsDir\FooSetup.exe" /S /D=$ProgramFiles\Foo' # This is the syntax for NSIS installers
SectionEnd

Section "Bar 2015"
DetailPrint "Installing Bar 2015"
File "BarSetup.msi"
ExecWait '"MSIEXEC" /qb /i "$PluginsDir\BarSetup.msi" REBOOT=ReallySuppress' 
SectionEnd

Section -Cleanup
SetOutPath "$Temp" # Release current directory lock on $PluginsDir
SectionEnd

If this solution is not possible then you are looking at some form of automation like the other answers have suggested.

I'd say there are two forms of automation; one where the app you are automating has to be the active window and the other where you send messages instead of keystrokes.

Just sending Enter to the active window with some sleep's thrown in is of course the easy solution but it can break if somebody starts interacting with the machine.

NSIS supports commands like FindWindow and SendMessage and I assume AutoHotkey does as well. The advantage to using FindWindow to find a specific HWND and then sending it a message directly is of course that the application does not have to have keyboard focus. This approach requires a bit more work but the end result is better because you only use SendMessage after finding the right window (and you can make sure the window/control is visible and enabled etc) so you know the application is in a known state without having to hope that the sleep was long enough...

Anders
  • 97,548
  • 12
  • 110
  • 164
1

Installing other installers is no problem with any decent installer builder.

These other installers are either msi, exe or zip files.

I do not assume that the installers (for SQL database servers and the like) offer silent install (by way of a million command-line parameters or a config file).

I highly doubt I can launch these installers in silent mode (with a million command line parameters)... :-(

Fetch the installer for the SQL database server and check it. Most of the installers offer a silent install.

  • msi or exe files created by another installer builder accept CLI arguments to select components and set the target path
  • even exe files created as SFX archives accept a target path for the unpackaging
  • some installers do not provide all form-fields of their GUI configuration dialogs as CLI parameters. for those installers you would need a post-configuration step, which might simply consist of copying a default config file into the application folder
  • Yes, its also possible to center an installer around the idea of "gui automation" or "inserting keystrokes" using AutoIt, AutoHotkeys or any other Automation tool from inside the main installer.
    • You would need to build an automation script for each installer and execute it from the main installer. Its probably nice for testing and replaying the individual component installations.
    • But YAGNI.

Given that I need to do this, what's the best way to go about it?

Make a full run and note all the installation steps.

  • list the installers you need
  • find the download urls
  • download the installers
  • download additional tools you need (unzip?)
  • for each installer check the CLI arguments it accepts
    • check if you get a decent default configuration, when leaving some CLI args away
  • install each installer from the CLI into your target location

Then translate the steps you have into the Installer builder of your choice. Its mostly copy pasting CLI commands into Exec() or ShellExec() calls, followed by copying config files and fiddling around with cross-component configuration.

I haven't seen that or even if they can be used to control other installers in a very detailed fashion

Just think of all the game installers shipping DirectX or the pre-packaged web-development stacks like XAMPP or WPN-XM (speaking of the last: you might take a look at this InnoSetup script file).

A wrapped installation of multiple software components is pretty common.

Community
  • 1
  • 1
Jens A. Koch
  • 39,862
  • 13
  • 113
  • 141
  • Wow, blast from the (Windows 98) past! I had completely forgotten about those (and haven't used Windows like that in many years). – KlaymenDK Nov 17 '15 at 09:33