Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Windows OLE in Perl, System Restore

by jupe (Beadle)
on Feb 06, 2013 at 16:09 UTC ( #1017463=perlquestion: print w/ replies, xml ) Need Help??
jupe has asked for the wisdom of the Perl Monks concerning the following question:

Hello wise monks, I am seeking guidance on a problem. I am attempting to create a System Restore point on a Windows 7 machine, and I cannot tell if the code I am using is as faulty as my intellect or if it is the machine that is the problem. Code posted below

use strict; use Win32::OLE('in'); use constant wbemFlagReturnImmediately => 0x10; use constant wbemFlagForwardOnly => 0x20; my $res = Win32::OLE->GetObject("winmgmts:\\\\.\\root\\default:Systemr +estore") or warn "WMI connection failed.\n"; my $test=$res->CreateRestorePoint("New Restore Point", 0, 100); print "$test";

Update: no actual updates, still just returning undef

I have a sneaking suspicion that even if the snippet above is perfect I still have environmental issues, however before I go and build another machine to test are there any obvious errors? The connection to WMI succeeds, but the return from CreateRestorePoint is undef. The documentation I am working from is located here: http://support.microsoft.com/kb/295299

Thank you!

Comment on Windows OLE in Perl, System Restore
Download Code
Re: Windows OLE in Perl, System Restore
by BrowserUk (Pope) on Feb 06, 2013 at 16:28 UTC
    the return from CreateRestorePoint is undef.

    What do you get if you print $^E? eg.:

    use strict; use Win32::OLE('in'); use constant wbemFlagReturnImmediately => 0x10; use constant wbemFlagForwardOnly => 0x20; my $res = Win32::OLE->GetObject("winmgmts:\\\\.\\root\\default:Systemr +estore") or warn "WMI connection failed.\n"; my $test = $res->CreateRestorePoint("New Restore Point", 0, 100) or die "CRP failed with: $^E"; print "$test";

    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
Re: Windows OLE in Perl, System Restore
by Anonymous Monk on Feb 07, 2013 at 08:02 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1017463]
Approved by marto
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (9)
As of 2014-10-02 04:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    What is your favourite meta-syntactic variable name?














    Results (49 votes), past polls