bigcreeklinn has asked for the wisdom of the Perl Monks concerning the following question:

Greetings. I am having trouble with the OLE ConnectServer method. I am calling this method within a loop, processing through about 25000 hosts, calling them via IP address. All is well except for 3 or 4 of these. For those, the method call does not return. I have to interrupt the script, remove the offending IP from the input stream, and then restart. The input IP's are all valid.

How do I handle this problem? Have I misread the Win32 documentation? To me it says that if I pass in 128 in the seventh position, the max wait will only be 2 minutes. Am I missing something in OLE?

I cannot fix the remote hosts. If this turns out to be an unavoidable problem in OLE, how do I best handle this in perl, enforcing my own timeout for the call?

Thanks.

my $ole = Win32::OLE->new('WbemScripting.SWbemLocator') or die "Can't start OLE"; # do some stuff to get a big list of ip addresses, hostnames, username +, and passwords foreach .... { # next if the ip does not ping... my $wmi = $ole->ConnectServer($ip, 'root/cimv2', $hostname.'\\'.$user, $pw, undef, undef, 128); # do some WQL stuff }

Replies are listed 'Best First'.
Re: OLE ConnectServer method does not return
by Anonymous Monk on Nov 15, 2011 at 03:44 UTC

    Have I misread the Win32 documentation?

    What documentation exactly?

      Sorry:
      http://msdn.microsoft.com/en-us/library/windows/desktop/aa393720(v=vs. +85).aspx