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:
- HKEY_CLASSES_ROOT &H80000000
- HKEY_CURRENT_USER &H80000001
- HKEY_LOCAL_MACHINE &H80000002
- HKEY_USERS &H80000003
- HKEY_CURRENT_CONFIG &H80000005
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???
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.