Microsoft Windows Management Instrumentation (WMI) offers numerous classes and properties that you can use to retrieve information about local and remote computers. The Windows Management Instrumentation Command-line (WMIC) utility brings that functionality to the command line. This article explores how you can use the Windows Management Instrumentation Command-line utility to retrieve the IDs of all the hotfixes installed on the local machine.
There are dozens of different ways to find the hotfixes installed on computers, but the fastest and simplest way is to use a widely available tool named Windows Management Instrumentation Command-line (WMIC). With WMIC, getting the IDs of all the hotfixes installed on the local system can be done with this short command
wmic qfe get Hotfixid
If you aren’t familiar with WMIC and want an even shorter command to remember, you can cut the command down to
Besides displaying the IDs, this command displays other details (e.g., hotfix name, hotfix installation date) about the installed hotfixes, which can be helpful.
If you just need to determine whether a specific hotfix is installed, you can avoid searching through a long list of hotfixes by piping the wmic qfe command’s output through the Find command. For example, if you want to see whether hotfix 938194 is installed on the local machine, you can run the command
wmic qfe | find “938194”
Note that you need to enclose the search string (in this case, 938194) in quotes.
At this point, you might be wondering what qfe is. In WMIC, you use aliases such as qfe to specify the Windows Management Instrumentation (WMI) class you’re interested in retrieving information from. In WMIC, an alias is essentially a nickname. Just like it’s easier to remember people’s nicknames than their full names, it’s easier to remember classes’ aliases than their full names. Besides helping with familiarity, aliases reduce what you have to type on the command line and can help differentiate between classes with similar names.
Although WMIC assumes that you’re using aliases on the command line, you can use standard Windows Management Instrumentation (WMI) class paths instead. For example, qfe is the alias for WMI’s Win32_Quick- FixEngineering class, therefore
wmic qfe get Hotfixid
is equivalent to
wmic path win32_quickfixengineering get Hotfixid
The path keyword that precedes the name of the WMI class tells WMIC that the path to a WMI class follows. So, if you don’t know a particular WMIC alias for a WMI class, all you need to do is use the path keyword followed by the class’s name.
There are several reasons why I use WMIC for checking hotfixes. As I mentioned earlier, it’s fast. You can type the entire command in an open command-prompt window more quickly than you can navigate to most programs on the Windows Start menu. It’s simple because you don’t need to install special programs to perform the query for you. Equally important, you can use it with virtually any Windows OS. Although WMIC has been around only since Windows XP, you can use WMIC’s /node parameter to run the utility remotely against earlier Windows OSs, as long as those OSs are running WMI. For example, to check for hotfixes on a Windows NT 4.0 system named LegacyHost that has the NT 4.0 WMI extensions installed, you’d run the command
wmic /node:legacyhost qfe get Hotfixid
There’s another reason to use WMIC for getting hotfix information. If you don’t already use WMIC, it gives you an opportunity to become familiar it, which has an immense long-term payoff: One tool is all you’ll need to find out information about any WMI property on any system you’re connected to. All you need to know is the property’s name and the appropriate alias. For example, if you want the names of all the printers on the local system, you’d use the printer alias with the Name property in the command
wmic printer get Name
Need the CPU speed on the local machine? Simply run
wmic cpu get CurrentClockSpeed
The built-in aliases that are available for use can differ depending on the OS you’re using. For example, if you need to find the memory currently installed on a Windows XP computer, you’d need to use
wmic memlogical get totalphysicalmemory
But on a Windows Server 2008, Windows Vista, or Windows Server 2003 machine, the command would be
wmic memorychip get Capacity
On the Windows IT Pro Web site, you can download a Microsoft Excel spreadsheet that shows the differences between WMIC aliases on various OS versions. Go to www.windowsitpro.com/Windows/Article/ArticleID/97781/97781.html and click the Download the Code Here button near the top of the page. The 97781.zip file that you download will contain the spreadsheet.
For more detailed information about WMIC’s options, you can check the built-in Help feature with one of the following commands:
Spending a little time learning about these options will pay off later when you need quick access to particular information about the systems you support.