Click here to get back home

Win32::OLE different connections methods produce different results

 HomeNewsGroups | Search | About
 comp.lang.perl.misc    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Win32::OLE different connections methods produce different results HmJ 03-28-2008
Posted by HmJ on March 28, 2008, 10:46 am
Please log in for more thread options
Hi,
It seems what when using perl Win32::OLE for WMI queries it produces
different results depending on method used to connect to server,
examples bellow, can somebody explain this issue?


Examples

Using ConnectServer() I get
ActiveSessions: 0
TotalSessions: 0

Script
#!/usr/bin/perl

use strict;
use Win32::OLE('in');

use constant wbemFlagReturnImmediately => 0x10;
use constant wbemFlagForwardOnly => 0x20;

my $computer = "server";
my $user = 'DOMAIN\USER';
my $pwd = "password";
my $wmipath = 'root\cimv2';

print "\n";
print "==========================================\n";
print "Computer: $computer\n";
print "==========================================\n";


        my $wmiwebloc = Win32::OLE->new('WbemScripting.SWbemLocator');
        my $wmi = $wmiwebloc->ConnectServer($computer,$wmipath,$user,$pwd);
        $wmi->-> = 3;

        if (Win32::OLE::LastError()) {
         print 'Authentication failed: ' . ('' . Win32::OLE::LastError()),
"\n";
        }



my $colItems = $wmi->ExecQuery("SELECT * FROM
Win32_PerfRawData_TermService_TerminalServices", "WQL",
wbemFlagReturnImmediately | wbemFlagForwardOnly);

foreach my $objItem (in $colItems) {
print "ActiveSessions: $objItem->\n";
print "Caption: $objItem->\n";
print "Description: $objItem->\n";
print "Frequency_Object: $objItem->\n";
print "Frequency_PerfTime: $objItem->\n";
print "Frequency_Sys100NS: $objItem->\n";
print "InactiveSessions: $objItem->\n";
print "Name: $objItem->\n";
print "Timestamp_Object: $objItem->\n";
print "Timestamp_PerfTime: $objItem->\n";
print "Timestamp_Sys100NS: $objItem->\n";
print "TotalSessions: $objItem->\n";
print "\n";

}


Output
==========================================
Computer: server
==========================================
ActiveSessions: 0
Caption:
Description:
Frequency_Object: 10000000
Frequency_PerfTime: 2605950000
Frequency_Sys100NS: 10000000
InactiveSessions: 0
Name:
Timestamp_Object: 128511849607031250
Timestamp_PerfTime: 5097696116216139
Timestamp_Sys100NS: 18446742399360059616
TotalSessions: 0



While Using Win32::OLE->GetObject I get
ActiveSessions: 1
TotalSessions: 2

Script
#!/usr/bin/perl

use strict;
use Win32::OLE('in');

use constant wbemFlagReturnImmediately => 0x10;
use constant wbemFlagForwardOnly => 0x20;

my $computer = "server";
my $user = 'Domain\User';
my $pwd = "password";
my $wmipath = 'root\cimv2';


print "\n";
print "==========================================\n";
print "Computer: $computer\n";
print "==========================================\n";

my $wmi = Win32::OLE->GetObject("winmgmts:\$computer\root\
\CIMV2") or die "WMI connection failed.\n";


my $colItems = $wmi->ExecQuery("SELECT * FROM
Win32_PerfRawData_TermService_TerminalServices", "WQL",
wbemFlagReturnImmediately | wbemFlagForwardOnly);

foreach my $objItem (in $colItems) {
print "ActiveSessions: $objItem->\n";
print "Caption: $objItem->\n";
print "Description: $objItem->\n";
print "Frequency_Object: $objItem->\n";
print "Frequency_PerfTime: $objItem->\n";
print "Frequency_Sys100NS: $objItem->\n";
print "InactiveSessions: $objItem->\n";
print "Name: $objItem->\n";
print "Timestamp_Object: $objItem->\n";
print "Timestamp_PerfTime: $objItem->\n";
print "Timestamp_Sys100NS: $objItem->\n";
print "TotalSessions: $objItem->\n";
print "\n";

}

Output
==========================================
Computer: server
==========================================
ActiveSessions: 1
Caption:
Description:
Frequency_Object: 10000000
Frequency_PerfTime: 2605950000
Frequency_Sys100NS: 10000000
InactiveSessions: 1
Name:
Timestamp_Object: 128511890915625000
Timestamp_PerfTime: 5108460132511734
Timestamp_Sys100NS: 18446742440665596616
TotalSessions: 2



Similar ThreadsPosted
did not produce a valid header June 20, 2005, 12:32 pm
One liner to produce string of n '?'s separated by commas ... ? October 13, 2004, 2:15 pm
Forking and SSH connections June 26, 2007, 6:26 am
Pool of database connections July 11, 2005, 6:24 pm
How to use threads to parallelise 4 different DB connections? July 27, 2006, 1:24 am
how to create persisitent tcp connections using perl November 18, 2005, 2:23 am
IO::Socket Stop listening for new connections after initial connection January 13, 2006, 12:54 pm
handling hanging database connections: timeout in perl November 24, 2006, 8:06 am
Dave Roth's site (Win32::AdminMisc, Win32::ODBC, etc.) not available. December 22, 2005, 7:38 am
Overriding *all* methods August 25, 2004, 8:36 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap