Thanks for the reference.  I'm trying to make it work using "WbemScripting.SWbemRefresher".... which I believe is required to see changing values ... but I get an "Access Denied" error with the AddEnum method.  The AddEnum method does show up in Jan Dubios' Win32::OLE Type Library Browser.  ["Microsoft WMI Scripting V1.2 Library" -> "SWbemRefresher"]

This time I searched all of the list archives and found only one other reference... where someone else had problems using the OLE object "WbemScripting.SWbemRefresher".

Perl script follows that demonstrates the problem.  

Regards,

... Dewey



use strict;
use warnings;

use Win32::OLE qw(in);

$Win32::OLE::Warn = 3;

my $strComputer = '.';

my $objRefresher = Win32::OLE-> new('WbemScripting.SWbemRefresher');

my $objWMIservice = Win32::OLE->GetObject('winmgmts:{impersonationLevel=impersonate}!//' . $strComputer . '/root/cimv2')
        or die "could not GetObject objWMIservice ", Win32::OLE->LastError;

my $objRefreshableItem = $objRefresher->AddEnum($objWMIservice, "Win32_PerfFormattedData_Tcpip_NetworkInterface")->ObjectSet
        or die "could not set objRefreshableItem ", Win32::OLE->LastError;

$objRefresher->Refresh;

foreach my $i (1..3) {
    print "Refresh number $i\n";
    $objRefresher->Refresh;
    foreach my $objItem (in $objRefreshableItem->ObjectSet) {
        print $objItem->Name, "\n";
    }
}

Script dies with the following output.

C:\My Documents\Perl Stuff>perl wmiperf.pl
OLE exception from "SWbemRefresher":

Access denied

Win32::OLE(0.1704) error 0x80041003
    in METHOD/PROPERTYGET "AddEnum" at wmiperf.pl line 15




"Paul Sobey" <[EMAIL PROTECTED]> wrote on 05/07/2006 01:57:12 PM:

> > Anyone have any guidance on how to determine the numbers of
> > network (TCP) bytes and/or packets sent / received over a TCP
> > interface from a Perl script (AS 5.8.8 build 817)?  Is there
> > some method to get this information from WMI (?) or some
> > other internal / system level Windows XP interface?
> >
> > I've written a perl script that use OLE automation to drive
> > Internet Explorer to access a website and follow a couple of
> > links.  I'd like to be able to capture the number of network
> > bytes sent / received (and packets too) that occur while IE
> > is executing under the Perl script's control.    I know I
> > could get the length of the "outerHTML" from the IE document
> > ($IE->{Document}->body->{outerHTML}) which approximates the
> > number of bytes received... but I'm looking for something better.
> >
> > Working code snippets are always greatly appreciated but even
> > the basics on how to go about getting this information from a
> > perl script would be great...
>
> Hey,
>
> The WMI performance counters will do the job for you. See
> http://msdn.microsoft.com/library/default.asp?url=""> > wmi/performance_counter_classes.asp, and in particular
> http://msdn.microsoft.com/library/default.asp?url=""> > wmi/win32_perfformatteddata_tcpip_networkinterface.asp
>
> Hope that gives you some pointers - there are sample scripts on the site
> which should be easily convertable to perl.
>
> Good luck!
>
> Cheers,
> Paul
>
> ----
> Gloucester Research Limited believes the information provided herein
> is reliable. While every care has been taken to ensure accuracy, the
> information is furnished to the recipients with no warranty as to
> the completeness and accuracy of its contents and on condition that
> any errors or omissions shall not be made the basis for any claim,
> demand or cause for action.
> The information in this email is intended only for the named
> recipient.  If you are not the intended recipient please notify us
> immediately and do not copy, distribute or take action based on this e-mail.
> Gloucester Research Limited, 5th Floor, Whittington House, 19-30
> Alfred Place, London WC1E 7EA.
> ----
>
_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to