Monday, February 6, 2012

A Basic Package Scripting Exercise

The following is an excerpt from a screening exercise we use to evaluate potential candidates for positions involving software repackaging and deployment.  There's much more to the screening and evaluation, so this is just a sampling.  After looking it over, read my comment at the end.


BEGIN


Exercise 1 - Installation

Create a script (using template A, below) to install a product named "Fubar 2012" using the vendor-provided "fubar12.msi" file.  This installation will be deployed with Configuration Manager 2007, which will use the local SYSTEM account to perform all tasks, unattended, regardless of a (human) user being logged on or not.

Your script will need to perform the following tasks:

  • The installation needs to specify the USERNAME property as "IT Services" and the COMPANYNAME property as "Contoso Corporation" during the installation.
  • The .MSI installation should create a log file named "cvb_fubar2012.log" in the TEMP folder.  It is important to NOT hard-code the path to the "temp" folder, but use a Windows environment variable instead.
  • After the .MSI installation, the script needs to copy a shortcut file named "Fubar 2012.lnk" from the script source directory down to the "All Users" Start Menu, under "Programs\Fubar 2012".  Keep in mind that this will need to work for Windows XP and Windows 7 installations.
  • Download a license file named "license.dat" from the script source directory into the application installation folder:   "%ProgramFiles%\Fubar 2012\bin"
  • Create a new Registry value under the application registry key path: HKLM\SOFTWARE\FUBAR\2012\Options, named "CheckForUpdates", with a REG_DWORD value of 0 (zero).
  • Adjust folder permissions on the installation folder: "C:\Program Files\Fubar 2012" to allow members of the group "Contoso\Domain Users" to have "Change" (modify) permissions

Important:  Remember that when deploying scripts and packages with products like Configuration Manager, you cannot be certain as to where the package will be deployed from.  The deployment system manages the distribution of packages to a network of "Distribution Point" servers.  Therefore, it is important that you never assume the script source path, but use a self-referencing path variable instead, such as "%~dp0" or "%~dps0", etc.

Exercise 2 - Uninstall

You will use a separate script (using template B, below) to uninstall Fubar 2012.   After inspecting the Registry, you determine that the application stores the uninstall reference under the GUID:  {00001111-3ABC-DEFG-1234-0123456789AB}

Your script will need to perform the following tasks:

  • Execute a silent uninstall of the .MSI package using the GUID (above), making sure to suppress a restart afterwards
  • Handle the scenario when script is run on a client that does not have the application installed (exit / abort gracefully)
  • Remove leftover folder and files: "C:\Program Files\Fubar 2012"
  • Remove leftover registry keys: "HKLM\SOFTWARE\Fubar"
  • Remove the Start Menu shortcut and the sub-folder it was added to (for Windows XP and Windows 7 installations)

Comment:

After fielding this to a long list of candidates, so far, not one has passed with flying colors.  Not one.  This is considered by most packagers to be a "basic level" test.  The best we've come to expect is determining how close to "correct" each candidate is and use that to determine how much (if any) training is required to close the gaps in their skills.

I have to say I'm extremely disappointed in the results our search for candidates within the United States.  We have listings on multiple services, web sites, Facebook, Google+ and Twitter and applicants are just not there.  If the job didn't require on site working in Virginia we'd focus on searching overseas.  I'm still holding out hope.

The other parts we evaluate include working with AdminStudio, InstallShield, troubleshooting file and folder permissions, registry permissions, managing services and processes, user context issues, System Center Configuration Manager (packages, programs, advertisements, collections, status monitoring, troubleshooting, client management, etc.).  After this we evaluate the candidate based on communication skills, professional attitude, courtesy, and so on.  If they don't root for one of our favorite football teams they're definitely eliminated (just kidding).

Template A

@echo off
rem ****************************************************************
rem  Filename..: install.cmd
rem  Author....:  (replace with your name)
rem  Date......: 01/18/2011
rem  Purpose...: install application name
rem ****************************************************************
CLS
SETLOCAL
SET APPNAME=ApplicationName
SET LOG=%TMP%\CVB_%APPNAME%_install.log
echo %DATE% %TIME% installing... %APPNAME%... >%LOG%
echo %DATE% %TIME% source....... %~dp0 >>%LOG%
echo %DATE% %TIME% target....... %COMPUTERNAME% >>%LOG%
echo %DATE% %TIME% windir....... %WINDIR% >>%LOG%
echo %DATE% %TIME% progfiles.... %PROGRAMFILES% >>%LOG%
echo %DATE% %TIME% temp......... %TMP% >>%LOG%
echo ----------------------------------------------- >>%LOG%
rem     perform MSI installation here
rem     echo result to log file
rem     handle failure of MSI installation here (exit/abort)
rem     copy shortcut file to start menu
rem     copy license data file
rem     create registry value
rem     echo result to log file
rem     adjust folder permissions
echo ----------------------------------------------- >>%LOG%
rem     echo exit code to log file
ENDLOCAL
rem     return final exit code here

Template B

@echo off
rem ****************************************************************
rem  Filename..: uninstall.cmd
rem  Author....:  (replace with your name)
rem  Date......: 01/18/2011
rem  Purpose...: uninstall application name
rem ****************************************************************
CLS
SETLOCAL
SET APPNAME=ApplicationName
SET LOG=%TMP%\CVB_%APPNAME%_uninstall.log
echo %DATE% %TIME% installing... %APPNAME%... >%LOG%
echo %DATE% %TIME% source....... %~dp0 >>%LOG%
echo %DATE% %TIME% target....... %COMPUTERNAME% >>%LOG%
echo %DATE% %TIME% windir....... %WINDIR% >>%LOG%
echo %DATE% %TIME% progfiles.... %PROGRAMFILES% >>%LOG%
echo %DATE% %TIME% temp......... %TMP% >>%LOG%
echo ----------------------------------------------- >>%LOG%
rem    perform MSI uninstall here
rem    echo result to log file
rem    handle failure of MSI installation here (exit/abort)
rem    remove shortcut file and app folder from start menu
rem    check for leftover files and folders, remove them if found
rem    remove leftover registry key path
rem    echo result to log file
echo ----------------------------------------------- >>%LOG%
rem     echo exit code to log file
ENDLOCAL
rem    return final exit code here

1 comment:

Jose Guia said...

Ooh looks like fun .. I have written quite a few of these .. I was going to share a screen of my deployment app and totally forgot .. email on its way.