in reply to Perl - WMI - BCD

This may not help much, but reading the Win32::OLE yields this nugget:
Warn     This variable determines the behavior of the Win32::OLE modulewhen an error happens. Valid values are:
0 Ignore error, return undef
1 Carp::carp if $^W is set (-w option)
2 always Carp::carp
3 Carp::croak

The error number and message (without Carp line/module info) are available through the "Win32::OLE-"LastError> class method.

Alternatively the Warn option can be set to a CODE reference.
E.g.

Win32::OLE->Option(Warn => 3); is equivalent to Win32::OLE->Option(Warn => \&Carp::croak); This can even be used to emulate the VisualBasic "On Error Goto Label" + construct: Win32::OLE->Option(Warn => sub {goto CheckError}); # ... your normal OLE code here ... CheckError: # ... your error handling code here ...

So, firing up an w32 box (w2k) and adding a shebang, #!C:/perl/bin -w, this is the output:

F:\_wo\pl_test>perl 696125.pl Win32::OLE(0.1701) error 0x80041002 after character 0 in "winmgmts:{impersonationlevel=impersonate,(Backup,Restore)}\\localhost +\root\wmi:BcdStore" at 696125.pl line 14 eval {...} called at 696125.pl line 14 Can't call method "OpenStore" on an undefined value at 696125.pl line +16.

And, compounding my demonstration of iggerance, as applied to your comment,

It looks like the previous line openstore is not assigning the store to $bcdst

I don't see how the openstore line would assign a value to a var declared without a value at your line 15.

UpdateFixed code tags

Replies are listed 'Best First'.
Re^2: Perl - WMI - BCD
by GrandFather (Saint) on Jul 08, 2008 at 02:19 UTC

    I seem to recall (but can't quickly find examples) that Win32::OLE can do funny stuff where it sets variables passed into its functions to be references to stuff. The openstore line is very likely correct in that respect.


    Perl is environmentally friendly - it saves trees
Re^2: Perl - WMI - BCD
by ChrisLD (Initiate) on Jul 08, 2008 at 01:54 UTC
    As this is attempting to access the BCD this script will only work on W2K8 and Windows Vista.

      From technet's troubleshooting help" in the subhead, "My script doesn’t return any data," (and possibly related to your OS vs what I have available, but maybe not):

      Note. Instead of an error 0x80041010, you might get error 0x80041002 (“Object could not be found”) or error 0x80041006 (“Insufficient memory”) when trying to connect to a nonexistent class.