Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Enumerate hotfixes applied to a Windows server (2000, 2003)

by grinder (Bishop)
on May 04, 2005 at 12:53 UTC ( #453916=snippet: print w/ replies, xml ) Need Help??

Description:

I needed to go through a number of servers and check what hotfixes had been installed. I had a feeling Win32::TieRegistry could do that for me. The code needed to do so is surprisingly short.

It took me about 20 seconds to read the documentation and do the following. Bravo tye. My only gripe is that I typed in slashes rather than backslashes, and it didn't like that (although this was written on a 5.6.1 installation, for all I know this is fixed in more recent versions).

#! perl -w

use strict;
use Win32::TieRegistry;

use constant BASE => 'LMachine\\Software\\Microsoft\\Windows NT\\Curre
+ntVersion\\HotFix\\';

my $fix = $Registry->{+BASE} or die "oops, not admin? ($^E)\n";

foreach my $f( sort keys %$fix  ) {
    chop(my $id = $f);
    my $desc = $Registry->{BASE.$f}{Comments} || '<no description>';
    print "$id\t$desc\n";
}
Comment on Enumerate hotfixes applied to a Windows server (2000, 2003)
Download Code
Re: Enumerate hotfixes applied to a Windows server (2000, 2003) (import)
by tye (Cardinal) on May 05, 2005 at 02:45 UTC

    Thanks.

    use Win32::TieRegistry( Delimiter=>"/" );

    You should have spent 35 seconds reading the documentation. (:

    Actually, I prefer the newer usage:

    my $Reg; use Win32::TieRegistry( Delimiter=>"/", TiedRef=>\$Reg );

    Then use $Reg (or whatever you name your variable) instead of the old $Registry global that gets exported by default (for backward compatability with earlier versions).

    Note that $Registry->{BASE.$f}{Comments} is better written $fix->{$f}{Comments} or $fix->{"$f/Comments"}, since you've already got the BASE() key open.

    - tye        

      Also, since you are not changing the registry, it seems safer to use Access => 'KEY_READ'.

Back to Snippets Section

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: snippet [id://453916]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (5)
As of 2014-10-24 21:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (137 votes), past polls