Again, for all OLE gurus... This should be an easy one for somebody. Using Win32::OLE, once I connect to root\default, I get the StdRegProv object. This object has an EnumKey method, which I am trying to call. The very first input value of this method is hexadecimal... and I can't quite format my variable correctly to get it to accept it. Here's the stuff:
@host = ($server,"root/default",$user,$password); $localWMI = Win32::OLE->new('WbemScripting.SWbemLocator') or die "Cann +ot access WMI on local machine: ", Win32::OLE->LastError; $WMI = $localWMI->ConnectServer(@host) or die "Cannot access WMI on re +mote machine: ", Win32::OLE->LastError; $registry = $WMI->Get("StdRegProv") or print "Failed to get registry." +; my $err = Win32::OLE->LastError(); if ($err == 0) {print "Successful!\n";} else {print $err;} $base = "Software\\"; $registry->EnumKey('H80000002', $base, @result); my $err = Win32::OLE->LastError(); if ($err == 0) {print "Successful!\n";} else {print $err;}
From all the <gag> VBS </gag> code I can gather from other sources, the constants that the first field accepts are: In CScript, the constant is of course set simply as
Const HKEY_LOCAL_MACHINE = &H80000002

(ref: Microsoft's site...)

No matter how I try to set the variable, I always get: OLE exception from "SWbemObject": Type mismatch Win32::OLE(0.1502) error 0x80041005 in METHOD/PROPERTYGET "EnumKey"

Anybody know the correct format to pass a hexadecimal value to an OLE method call???


In reply to Pass Hexadecimal through OLE method? by jpavel

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.