Hello, monks. I have a problem with gathering some information from Win registry.

My code works well when it comes to finding installed programs:

sub scan_installed { system ('reg query HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\ +Uninstall /s > temp_instal.txt'); open (INSTAL, "<", 'temp_instal.txt') or die "Couldn't open temp_i +nstal.txt for reading: $!\n"; while (<INSTAL>) { if (/DisplayName\s+REG_SZ\s+(.+)/) { push (@installed, $1."\n") unless $1 =~ /Windows XP|KB[0-9 +0-90-9]/; } } close(INSTAL); system ('del temp_instal.txt'); }

My problem is - I want to find out the version (and presence) of Adobe Reader, flash plugin, .NET framework and some other programs. The input data (INSTAL) looks like this:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall +\{AC76BA86-7AD7-1033-7B44-A80000000002} AuthorizedCDFPrefix REG_SZ Comments REG_SZ Contact REG_SZ Customer Support DisplayVersion REG_SZ 8.0.0 HelpLink REG_EXPAND_SZ http://www.adobe.com/support/main.htm +l HelpTelephone REG_SZ InstallDate REG_SZ 20080326 InstallLocation REG_SZ InstallSource REG_SZ C:\SWTOOLS\APPS\Adobe\AdbeRdr80\EN\ ModifyPath REG_EXPAND_SZ MsiExec.exe /I{AC76BA86-7AD7-1033-7 +B44-A80000000002} NoRepair REG_DWORD 0x1 Publisher REG_SZ Adobe Systems Incorporated Readme REG_EXPAND_SZ C:\Program Files\Adobe\Reader 8.0\Reade +r\Readme.htm Size REG_SZ EstimatedSize REG_DWORD 0x13b54 UninstallString REG_EXPAND_SZ MsiExec.exe /I{AC76BA86-7AD7-1 +033-7B44-A80000000002} URLInfoAbout REG_SZ http://www.adobe.com URLUpdateInfo REG_SZ http://www.adobe.com/products/acrobat/r +eadstep.html VersionMajor REG_DWORD 0x8 VersionMinor REG_DWORD 0x0 WindowsInstaller REG_DWORD 0x1 Version REG_DWORD 0x8000000 Language REG_DWORD 0x409 DisplayName REG_SZ Adobe Reader 8

I think that what I need to do, is - for every line beginning with HKEY check the following indented lines for DisplayName, and if it matches a given pattern (Adobe Reader), find the corresponding line with DisplayVersion. But (as in the given example) sometimes DisplayVersion comes first, sometimes it doesn't.

Any ideas on how I could find the version of a given program?

Regards,
Luke


In reply to Finding installed program version in Win32 registry by 1Nf3

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.