Hack 82 Enumerate Installed Hotfixes

 < Day Day Up > 

figs/beginner.gif figs/hack82.gif

Here's a script you can use to list all hotfixes installed on a machine .

Ever wish you could quickly and easily look at a computer and find out which hotfixes were installed, when they were installed, and by whom? Here is a sample script that shows you how to accomplish this; if you know VBScript and WMI, you can customize it further as necessary. This script will enumerate the installed hotfixes on a computer and display the output in a message box.

The following items will be displayed about each installed patch: the name of the computer on which the hotfix is installed, the description of the hotfix, the hotfix ID, the installation date, and who installed the hotfix .

The Code

Type the following code into Notepad (with Word Wrap disabled) and save it with a .vbs extension as EnumerateHotfixes.vbs :

 strComputer = "." Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\" & strComputer & "\root\cimv2") Set colQuickFixes = objWMIService.ExecQuery _ ("Select * from Win32_QuickFixEngineering") For Each objQuickFix in colQuickFixes Wscript.Echo "Computer: " & objQuickFix.CSName & vbCrlf &_ "Description: " & objQuickFix.Description & vbCrlf &_ "Hotfix ID: " & objQuickFix.HotFixID & vbCrlf &_ "Installation Date: " & objQuickFix.InstallDate & vbCrlf &_ "Installed By: " & objQuickFix.InstalledBy & vbCrlf Next 

Running the Hack

Open a command prompt, change to the directory in which the script is located, and type cscript.exe EnumerateHotfixes.vbs . Figure 9-1 shows sample output from running the script.

Figure 9-1. Enumerating hotfixes on a Windows 2000 machine
figs/wsh_0901.gif

To ensure the script works properly, make sure you have the latest scripting engines on the workstation from which you run this script. You can download the latest scripting engines from the Microsoft Scripting home page (http://msdn.microsoft.com/scripting/). Also, since the script uses the Active Directory Services Interface (ADSI), you must have the same applicable rights you need to use the built-in administrative tools.

Hans Schefske

 < Day Day Up > 


Windows Server Hacks
Windows Server Hacks
ISBN: 0596006470
EAN: 2147483647
Year: 2004
Pages: 163
Authors: Mitch Tulloch

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net