Hi,

I would like to check if registry key is exist by the following simple Perl code:

my $UninstallRegistryPATH = "HKLM\\SOFTWARE\\Microsoft\\Windows\\Curre +ntVersion\\Uninstall\\{30277218-0100-0904-9ABB-000BDB5CF35D}"; my $cmd = "REG QUERY ${UninstallRegistryPATH}"; print "\n----$cmd----\n\n"; my @RegKeys = `$cmd 2>&1`; foreach my $var (@RegKeys) { print "$var" }
Output ERROR is:
----C:\Windows\system32\reg.exe QUERY HKLM\SOFTWARE\Microsoft\Windows\ +CurrentVersion\Uninstall\{30277218-0100-0904-9ABB-000BDB5CF35D}---- ERROR: The system was unable to find the specified registry key or val +ue.

If I run the command ($cmd) from the command line it run successfully.

Do someone have any idea?

Please advice

Thanks

I Failed even if i use the following code:

use Win32::Registry; my $Register = 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{0 +34106B5-54B7-467F-B477-5B7DBB492624}'; my $hkey; $HKEY_LOCAL_MACHINE->Open($Register,$hkey)|| die print "($!) ($?) ($^E +)\n"; $hkey->Close();

If i remove the last entrance key {034106B5-54B7-467F-B477-5B7DBB492624} and run it like the following is working good:

use Win32::Registry; my $Register = 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall'; my $hkey; $HKEY_LOCAL_MACHINE->Open($Register,$hkey)|| die print "($!) ($?) ($^E +)\n"; $hkey->Close();

My question is why? Why {034106B5-54B7-467F-B477-5B7DBB492624} caused to read problem?

I just need to check if some product is installed


In reply to Failed to check if registry key is exist by roteme

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.