Windows Application Automation 101

No Comments »
Wrote this up today for someone, and decided to clean this up a little and drop it here, since the few technical articles I post seem to get a lot of hits (compared to the rest of the blog). 
MSI (The Easy Way)
In the case of MSI, this will almost always be your command line for hands-free installation:
  • Msiexec /i {InstallerFile.msi} /qb
    • (/qb = quiet basic – will show progress bars, but not ask any questions, this is preferable to completely silent /qn, at least to test)
For other applications and installers, they’re either an MSI wrapped in a single executable (like Acrobat Reader), or a different type of installer (like Nullsoft Installer) and will have their own switches.  Below are a few of the tricks and tools I use to find out how best to get these applications into “silent” mode as much as possible.

Tools You Will (Probably) Need
  • Universal Silent Switch Finder (USSF) http://www.msfn.org/board/topic/17940-universal-silent-switch-finder-01/
  • Universal Extractor (install this on your system, it’ll give you the ability to right-click on many executables and extract them into a folder) http://legroom.net/software/uniextract
  • WinRAR (also handy for pulling apart some installers)
  • Procexp.exe Process explorer, great for determining command line of a nested installer after you run the “big” installer http://technet.microsoft.com/en-ca/sysinternals/bb896653.aspx
  • Elevated Shortcut to give the ability to run certain apps without UAC or administrator capabilities on a “per shortcut” basis, can upgrade an existing shortcut to have admin rights, or create a completely new one.
    • Very useful if there’s an executable/installer that only runs with Admin capabilities
    • Some only need admin rights during install or the first time they’re run
    • Can be used for non-admins to install things in a one-off fashion (printer drivers) or VPN client, etc
    • http://topsoftzone.com/program/9686/Elevated_Shortcut.html
  • A disposable Virtual Machine of WinXP or Win7

    • Set to snapshot so you can rollback often, nothing but updates installed so you can install all/one app and then roll it back if it works as expected, leaving a clean machine for further testing.
  • Steve’s Explorer Bar (StExBar) from Tortoise (the same people that make SVN) http://tools.tortoisesvn.net/StExBar.html
    • Once installed, you can enable the new StEx toolbar in the Windows Explorer that will give you the ability to copy either the filename only or the full path of a file without having to ever type it out, very useful when scripting installations
  • Uninstall Cleanly (also known as “UnClean2.0”) which can display all of your installed applications, and with most of the apps, it will also show the UNINSTALL command line, which can be used to remove previous versions if necessary
  • WPIW: Windows Post Installation Wizard
    • Pretty front end for scripted/batched commands
    • http://www.wpiw.net/
Option #1: USSF
  • If you take the installer file and drag/drop it onto the USSF.exe
    • You should be given back the switches that it can find for that type of file (things like /S and /SuppressSilent /NoReboot)
    • Copy/paste those into a command line and test to see if you can install it cleanly while running Silent
Option #2: Extract via WinRar/Universal Extractor
  • If you can, right-click and “WinRar” or “UniExtract to Subdir” the installer into a folder, and find the setup.exe or similar in there, and return to Option #1 to see if you can run a silenced install.
Option #3: Run and Trap the Installer
  • In some cases, you can run the installer, stop at the first “Next” screen, and then open Process Explorer and see what the nested executable is (under the base setup.exe, you might see a child process in a temp or AppData folder somewhere.  Go grab that folder and see what’s in there.)
    • This is especially true for applications like Chrome and Shockwave Player that have small “helper” applications for download, but then pull down the “real” installer and run that.  If a 40MB app has a 300K installer, you know something’s up.
      • Watch out for these, as they will often delete the “helper” app once the full installer’s been downloaded, thus killing your automation by removing the installer’s executable.
    • Once you’ve got that folder, look for executables and drop them on the USSF again, to see what you can find.
Option #4: Is there a portable version?
  • Sometimes there’s no graceful way to install an application, but if you still want to install it quickly to a number of workstations, see if perhaps the developers offer a “portable” version of the app.  One that runs completely out of the installation folder, without any installation necessary.

Note: Portable applications are not listed as installed applications in the registry, so they’re effectively “invisible” to utilities that search systems for installed programs  Keep that in mind if you plan on going portable with something – you probably won’t be able to track it effectively.


Inserting Licenses and Keys:
  • Many applications have the ability to include the installation key in the installation (either in the command line, or in an XML or INI file in the install directory)
  • If you can’t find documentation from the originator of the software, try some of the large installation repositories like http://www.itninja.com (previously appdeploy.com) or Spiceworks databases before googling it
  • Remember that key automation could mean difficulty finding those keys again later, or having many seats with the same key unintentionally

Fonts:
Fonts can be copied into the target system’s “c:\Windows\Fonts\” folder or app by hand if you’re an admin, but if you forcibly copy them in via network access (\\machinename\c$\windows\fonts\), they won’t show up as usable until they’re been imported into the registry too.
  • Install the needed font(s) on your local machine via drag/drop
  • Start>run>regedit
    • Go to: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts
    • R-Click on the fonts folder and select export (export it to your desktop)
  • Open the resultant .reg file with a text editor
  • Delete all of the fonts listed in the exported file, except the ones you want to deploy
    • Also, Do NOT delete these lines:
    • Windows Registry Editor Version 5.00
    • [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts]
  • Copy the font TTF files to target’s Fonts folder, and import the .reg file with REGEDIT /S {Regfile}
  • Reboot the system

Once you have your installer figured out, you can add the executable to the Windows Post Installation tool (WPI) found in the \WindowsUpdates folder.
 
WPI and the collected installations:
  • After launching the WPI, click Config, and find the application you’re replacing, or updating.
    • Make sure the description is reasonable (add version numbers if it makes sense)
    • Check/Add the command line that you’ve found with full path based on the steps you went through above
    • Set which category and configurations need this app (Utilities/Base)
  • Save/Exit to go back to the main WPI screen
  • Select None, and check your new app only
  • Begin installation to test.
“Gotchas” and Things To Watch Out For
  • Always test your installations to find out what happens if there’s already an old/same version installed
    • Eg: New version of Firefox installation that takes 4 seconds to install is good – but one that blows away your saved passwords and settings is bad.
  • Run every app at least once to make sure it really did what you think it did – It may have completed installation successfully, but does it actually launch now?
    • Also check for any first-run weirdness (like checks for updates, or registration, or plugins)
  • For some installers, re-running the setup on a system that already has the app will uninstall it from the machine, or change the installation
    • Example: Office 2007 upgraded to Office 2010 can remove Access 2007, even if Office 2010 didn’t include it.
  • Also watch out for installers/updates that forcibly reboot your system when completed silently.
  • It’s common for apps to quit if they detect that msiexec is already running, so sometimes you need to leave a few seconds pause to let one installation finish before launching the next one
  • Is the application installed for ALL users, or just the currently logged-in user/admin?  Google Chrome is a good example of this.
  • Printers are also not installed globally unless specifically added with the /ga switch
    • Type the following into the command prompt:
      • rundll32 printui.dll,PrintUIEntry /ga /n\\server\printername
    • In other words, to add mylj03, the command line is:
    • rundll32 printui.dll,PrintUIEntry /ga /n\\server\mylj03
  • Try not to leave icons all over your user’s desktop – collect them into a folder under c:\users\public\desktop so they can’t delete them, but can copy them out onto their own desktop or quicklaunch bar if they want to.
    • Quick way is to move all *.lnk files at the end of your installation pass
Posted on May 22nd 2013 in Software
Copyright © 2024 Gecko Bloggle