Microsoft Windows Registry Guide, Second Edition
Inventorying Applications
One of the most common requests that I receive regarding Windows Installer–based applications is about inventorying the applications and features installed on users' computers. If you have a software management infrastructure already in place, you should use the tools that it provides. Also, the Application Compatibility Toolkit provides tools for collecting an application inventory. For more information about these tools, see http://www.microsoft.com/windows/appcompatibility/default.mspx. Otherwise, see Microsoft's TechNet Script Center (http://www.microsoft.com/technet/scriptcenter/default.mspx), which contains an awesome collection of useful scripts and has a few scripts that suit the purpose very well.
Listing 13-1 is a script that inventories the software installed on a computer running Windows XP. Listing 13-2 is a script that inventories the features for all software installed on a computer running Windows XP. These only inventory Windows Installer–based applications, though. Using Notepad, type each script and save it as a text file with the .vbs extension. In the CreateTextFile method (second line of Listing 13-1), you can change the path where the script creates the inventory. Make sure that the path exists; the script will create the file. To run each script, double-click the file.
Listing 13-1 Inventory.vbs
Set objFSO = CreateObject("Scripting.FileSystemObject") Set objTextFile = objFSO.CreateTextFile("c:\software.tsv", True) strComputer = "." Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colSoftware = objWMIService.ExecQuery _ ("Select * from Win32_Product") objTextFile.WriteLine "Caption" & vbtab & _ "Description" & vbtab & "Identifying Number" & vbtab & _ "Install Date" & vbtab & "Install Location" & vbtab & _ "Install State" & vbtab & "Name" & vbtab & _ "Package Cache" & vbtab & "SKU Number" & vbtab & "Vendor" & vbtab & _ "Version" For Each objSoftware in colSoftware objTextFile.WriteLine objSoftware.Caption & vbtab & _ objSoftware.Description & vbtab & _ objSoftware.IdentifyingNumber & vbtab & _ objSoftware.InstallDate2 & vbtab & _ objSoftware.InstallLocation & vbtab & _ objSoftware.InstallState & vbtab & _ objSoftware.Name & vbtab & _ objSoftware.PackageCache & vbtab & _ objSoftware.SKUNumber & vbtab & _ objSoftware.Vendor & vbtab & _ objSoftware.Version Next objTextFile.Close
Wscript.Quit
Listing 13-2 Software.vbs
strComputer = "." Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colFeatures = objWMIService.ExecQuery _ ("Select * from Win32_SoftwareFeature") For each objFeature in colfeatures Wscript.Echo "Accesses: " & objFeature.Accesses Wscript.Echo "Attributes: " & objFeature.Attributes Wscript.Echo "Caption: " & objFeature.Caption Wscript.Echo "Description: " & objFeature.Description Wscript.Echo "Identifying Number: " & objFeature.IdentifyingNumber Wscript.Echo "Install Date: " & objFeature.InstallDate Wscript.Echo "Install State: " & objFeature.InstallState Wscript.Echo "LastUse: " & objFeature.LastUse Wscript.Echo "Name: " & objFeature.Name Wscript.Echo "ProductName: " & objFeature.ProductName Wscript.Echo "Vendor: " & objFeature.Vendor Wscript.Echo "Version: " & objFeature.Version Next
Wscript.Quit
Updating Source Lists
After the question of inventorying Windows Installer–based applications, the next most common request I receive is about updating an application's source list. When you deploy a Windows Installer–based application, you specify a list of alternative locations from which Windows Installer can install files. This supports multiple installation locations from a single set of configuration files. If you deployed an application with an incorrect source list or you moved your administration installations, you must update the source lists on each client computer.
With earlier versions of Windows Installer, updating source lists was a difficult task. You had to deploy a registry hack. With the current versions, you can use the Custom Maintenance Wizard to deploy an updated source list. This is a far more elegant solution than deploying a registry hack. Chapter 17, “Deploying Office 2003 Settings,” tells you more about using the Custom Maintenance Wizard.