Install Shield Silent Installs

Install Shield Silent Installs
Photo by Kristina Flour / Unsplash

Install Shield has this nifty feature of being able to install packages in silent mode. This means that you can run setup.exe from the command prompt and it will install in the background with no user interaction. This is very useful if you want to test your installation.

If you use some sort of continuous integration system (and you should if you don't) then you could download the latest installer do a silent install and run some tests against the program that is installed, then silent uninstall it all automat(g)ically.

To be able to do silent installs/un-installs you first need to record a response file that contains all the choices for the install shield dialogs.

To record the response file;

setup.exe -r

This will be like a normal install done manually. Follow it through like you would in any normal installation. After the installer exits, the response file should be at C:\Windows\setup.iss

Next time around you can do a silent install by running

setup.exe -s -f1<path to setup.iss>

I'm paranoid so I use the absolute path to the response file. There is no space between "-f1" and the path to setup.iss. Note that, when you run the
above command to silent install, the command will seem to exit immediately but if you check Task Manager you should see setup.exe (possibly 2 of them) running.

Silent un-installation is pretty much the same. You need to create a response file first. To do this run the following;

setup.exe -r -uninst -removeonly

This will again create a setup.iss file in C:\Windows I usually rename the uninstall response file as uninst.iss. Now you can do silent uninstallation by
running;

setup.exe -s -uninst -removeonly -f1<path to response file>

Some installers might install the program under different GUID's each time you install it. If this is the case I have found that the above command for uninstallation doesn't work, as Install Shield doesn't know what to uninstall.

The solution is to work out the UninstallString from the Registry (which is what Windows uses to uninstall the program via Add/Remove Software).

Here is a python script that uses the registry module (https://pypi.python.org/pypi/registry/) to find out the full UninstallString.

You first need to manually find this string
in your registry by looking under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall so that you can pass into this function a unique
string that is present in the UninstallString of your program

EDIT: the following script is quite ugly actually. I have a new version in which I use regobj it makes things easier.

import registry

def findUninstallStr(q):
    ''' q: some unique string that appears in the UninstallString value '''
    uninstallKey = 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall'
    for subkey in registry.GetSubKeys(uninstallKey):
        for (valuename, value, valuetype) in registry.GetKeyValues("%s\%s" %(uninstallKey, subkey)):
            if 'UninstallString' == unicode(valuename) and q in unicode(value):
                uninstallString = value
                return r"%s" %unicode(uninstallString)