Hi,
at work I need to get something working under windows 2k and following the instructions in this guide
http://www.microsoft.com/technet/scriptcenter/resources/qanda/nov04/hey1104.mspx
well, it does not work :(. Under xp it does, but upgrading is no option. So I thought, let's try it in perl instead.
this is what I got so far:
--------------------------script--------------- #!/usr/bin/perl use warnings; use strict; use Win32::OLE; my $WMIServices; my $Namespace = "\\root\\cimv2"; my $Machine = "."; my @files; my $strdate = "20031102000000.000000+000"; my $query = "Select * From CIM_DataFile Where CreationDate < '$strdate +' and drive = 'C:'"; print $query . "\n"; my $object = "winmgmts:\\\\$Machine$Namespace"; print $object . "\n"; $WMIServices = Win32::OLE->GetObject("$object"); @files = $WMIServices->ExecQuery("$query"); foreach (@files) { print "$_\n"; }
------------------------------------------------------ and this is what I get:
H:\scripts\perl\win32> perl wmi2.pl Select * From CIM_DataFile Where CreationDate < '20031102000000.000000 ++000' and drive = 'C:' winmgmts:\\.\root\cimv2 Win32::OLE=HASH(0x1986408)
Apparently I get the wmi statement ok, and the object too, but what under vbs works fine, under perl does not. I must be the cause, but I do not see it. Any ideas? thanks in advance

In reply to win32 wmi question by natxo

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.