A Guide to Installing Windows Applications Silently
When you manage a large number of computers, it becomes necessary to install software in many different circumstances. Many of these applications require a number of things be done after they are installed, such as adding licensing information, configuring options, adding components, etc. When you deal with many applications, it can become difficult to remember each and every tweak that needs to be done, and it can be time consuming to do them every time. For this reason, any time I have to install software on a computer, I spend the time to create a distribution point that contains a ‘silent install’, which is basically a script that installs and configures the software automatically. This takes a little more time upfront, but in the long run it will save you plenty of time and help eliminate many hassles.
Their are a number of ways to accomplish this. Some people prefer to use software like Prism Deploy to ‘capture’ all of the changes made to a computer when an installation is run, and create a ‘package’ that can be double-clicked, or even pushed out remotely. I’ve used these types of programs, and still do occassionally, but one down side to them is that when you run the capture, it captures every change that happened during your install, reguardless of whether that change was necessary for or even related to the installation. When you’ve worked with these for a while, you get a knack for which settings can be eliminated from the package, but their are many times when it’s unclear if a setting that was captured is needed or not. For this reason (I’m a bit more anal than the average person), whenever possible, I prefer to script a true installation process, so I’m only making changes to the computer that are required for the application I’m installing.
So, how do you make an application install itself without constantly asking you questions? Depends on the application. Some applications don’t offer a way to script their installation. In general, their are a few common ones that usually make silent installations easy, but even when an option to install silently is included, this doesn’t mean it will run the way you want. And once the application is installed, their’s the rest of those requirements that need to get met, which usually involve copying files and making changes to the registry.
So, where do we begin? Well, a first easy step is to create a base folder to put all of our individual application folders. Let’s call it %APPS%, which is a variable that can stand for whatever you’d like to call your folder. Inside of %APPS% will be a folder for each application that you wish to install. I try to give them all short names that still make it obvious what application we’re dealing with, but which are short enough to not have to do lots of typing when we need to refer to their location. Since I will occassionally be ‘working’ on a distribution, where it may not be ready to use yet, I preface those folder names with a hypen, making it clear that these are not ready to use in production.
Next, we need to obtain a few tools to help us with the process. Some of the tools we’ll use are built into Windows, so their is no need to download them. Other functions will require additional tools be added. Here are a few that we will need:
“AutoIt v3 is a freeware BASIC-like scripting language designed for automating the Windows GUI and general scripting. It uses a combination of simulated keystrokes, mouse movement and window/control manipulation in order to automate tasks in a way not possible or reliable with other languages (e.g. VBScript and SendKeys). AutoIt is also very small, self-contained and will run on 95, 98, ME, NT4, 2000, XP, 2003 out of the box with no annoying “runtimes” required! You can even make compiled executable scripts that can run without AutoIt being installed!”
Download the ZIP file from the link above, and extract the file AutoIT3.exe to the root of your %APPS% directory. It will be used by our installation scripts to do some of the tasks that command line switches and batch scripts cannot do. If you want to use AutoIT to create a new script, use the installer version ((http://www.autoitscript.com/cgi-bin/getfile.pl?autoit3/autoit-v3-setup.exe)) which includes tools to help find the names of elements you are trying to control, and also includes useful documentation.
“Loads Registry hives and modifies profiles for users who are not currently logged in. Can also be used to modify new user profiles (Default User).”
Download the ZIP file from the link above, and extract the file ModifyProfile.exe to the root of your %APPS% directory. It will be used by our installation scripts to make changes to the default user profile’s registry settings.
We need to change the format of the registry settings we feed into ModifyProfile. This will allow us to format the registry settings in our application scripts the same way they are exported through Regedit. Create a text file in the root of your %APPS% directory called ChangeHKCU.vbs and add the following text:
On Error Resume Next Set shell = WScript.CreateObject("WScript.Shell") Set FSO = WScript.CreateObject("Scripting.FileSystemObject") TempDir = shell.ExpandEnvironmentStrings("%TEMP%") FileContents = GetFile(TempDir + "\HKCU.reg") dFileContents = Replace(FileContents, "[HKEY_CURRENT_USER\", "[HKEY_USERS\TempHive\") WriteFile TempDir + "\HKCU.reg", dFileContents set shell = nothing '################## Functions ##################### ' Read a text file as a string Function GetFile(FileName) If FileName <> "" Then Dim FileStream on error resume Next Set FileStream = FSO.OpenTextFile(FileName) GetFile = FileStream.ReadAll End If End Function ' Write string as a text file. Function WriteFile(FileName, Contents) Dim OutStream on error resume Next Set OutStream = FSO.OpenTextFile(FileName, 2, True) OutStream.Write Contents End Function
“PrcView is a process viewer utility that displays detailed information about processes running under Windows. For each process it displays memory, threads and module usage. For each DLL it shows full path and version information. PrcView comes with a command line version that allows you to write scripts to check if a process is running, kill it, etc.”
Download the ZIP file from the link above, and extract the file PV.exe to the root of your %APPS% directory. It will be used by our installation scripts to pause the scripts until specific process finish, or to kill processes when needed.
“The DevCon utility is a command-line utility that acts as an alternative to Device Manager. Using DevCon, you can enable, disable, restart, update, remove, and query individual devices or groups of devices. DevCon also provides information that is relevant to the driver developer and is not available in Device Manager.”
Download the EXE file from the link above, and extract it to a temporary location. Copy the file devcon.exe from the i386 folder in the newly expanded files to the root of your %APPS% directory. It will be used by our installation scripts to deal with driver installations.
“This command-line tool offers a batch method for setting environmental variables in the user or system environment and requires no programming or scripting. In addition to taking an environmental variable and its associated value from the command line, it can also get the values of registrykeys and write them to text files.”
Download the EXE file from the link above, and install it on any computer. Once installed, copy the file Setx.exe from C:\Program Files\Resource Kit to the root of your %APPS% directory. It will be used by our installation scripts to read and set environment variables.
“NirCmd is a small command-line utility that allows you to do some useful tasks without displaying any user interface. By running NirCmd with simple command-line option, you can write and delete values and keys in the Registry, write values into INI file, dial to your internet account or connect to a VPN network, restart windows or shut down the computer, create shortcut to a file, change the created/modified date of a file, change your display settings, turn off your monitor, open the door of your CD-ROM drive, and more…”Download the ZIP file from the link above, and extract the file nircmd.exe to the root of your $APPS% directory. It will be used by our installation scripts to do a number of tasks (see www.nirsoft.net/utils/nircmd.html for a list of things this useful software can do).
With all of this in place, we’re ready to create some application distribution points. Each application will be a little different, so a few different techniques will be explained as we deal with each application individually. Check in the Silent Installs category for the applications that have been written up so far.
Posted: 06 March 16
Under: Silent Installs
Viewed: 45,491 views