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

Hi,

I am using Win32::TieRegistry to pull some information from the registry.

When I use the Connect method on the local machine, all is well.

When I try to use the Connect Method on a remote machine, I get the following error:

Overlapped I/O operation is in progress

Here's the code I'm using for the connect:

# Connect to a remote Registry key: $regKey= $Registry->Connect( $Machine, $target, { Access=>KEY_READ } ) or die "Can't connect to machine: $Machine : $^E\n";

The Connect method apparently works fine connecting to Windows NT Machines but fails consistently for Windows 2000 (Server and Professional) The target is defined as:

$target = "LMachine\\Software\\Microsoft\\Windows\\CurrentVersion\\Uni +nstall\\";

I am running ActivePerl build 5.8.0

The reason I am using this method of finding out what software is installed on a Windows machine is that WMI only returns software installed from an MSI file.

All help would be appreciated,

Kakaze

<update> I should have noted that I am running the script on a Win2K platform. </update>

Replies are listed 'Best First'.
Re: Win32::TieRegistry and Connect Method Errors (authenticate)
by tye (Sage) on Nov 12, 2003 at 20:24 UTC

    Sorry that I don't have time right now for a more thorough answer.

    Unfortunately, I don't think I ever found a clear-cut explanation for when you might get "Overlapped I/O operation is in progress". But I strongly suspect that the problem is one of authentication.

    Before trying to connect to the remote registry, authenticate with the remote server either with something hackish like:

    system("net use \\\\$Machine\\\$IPC"); #or, to be more eplicit (and get prompted for your password): system("net use \\\\$Machine\\\$IPC /user:domain\\you *");
    or using Win32::NetResource's AddConnection().

    There are also cases where SMB authentication will fail when using a computer name. So you might try using an IP address in $Machine instead.

                    - tye

      That's why I posted here, there is no clear cut reason for the error :{ In fact most of the info I found relating to that error related to some bug in IE3 :}

      There is possibly some other processes on the machines that are causing the errors but my indication that it was Win2K specific was based on tests of about a dozen machines here.

      I am not using threading or forking, it's a monolithic program.

      I've seen hints at suggestions of trying to authenticate to the machine before trying the Registry operation and I'll try running the program as the Domain Admin and see if that helps.

      Now that I've been pointed down the authentication track, it makes sense to connect as a power user (domain Admin or such) to the machines.

      With WMI, I can specify the user to connect as (Domain Admin) but with the registry probe, I'm attemtping to connect as an ordinary user.

      Thanks for the suggestions!

      Kakaze

      I don't know if there is an explicit need to connect to \\Machine\IPC$ since I just connect to the machine (see the post below).

      Perhaps the more enlightened can tell me why it would be advantageous to connect directly to the IPC?

      Also, it's IPC$ and not $IPC :).

        C:\>net use \\fs01 [...] D:\Callwave\Shared\IOCP>net use [...] OK \\fs01\IPC$ [...]

        Yes, newer versions of "net use" fill in the $IPC for you. I doubt anyone is still using "older" versions so there is no advantage.

                        - tye
Re: Win32::TieRegistry and Connect Method Errors
by BrowserUk (Patriarch) on Nov 12, 2003 at 23:25 UTC

    I don't think this error is directly related to Win32::TieRegistry. The are report of this same error occuring when using Win32::AdminMisc and Win32::NetAdmin::CreateUser

    Common elements seem to be apis that are communicating across the LAN, and an NT machine talking to a "K machine or vice versa.

    The error is indicating that a previous call to some (network) IO was started asynchronously, and it hasn't yet completed, or it hasn't been reset prior to another attempt being made to perform further IO.

    I think that you may be able to work around the problem by inserting a delay prior to calling which ever call is resulting in the error. I'd start with using 10 seconds, and if that is successful, slowly trim until the problem returns. I would use Win32::Sleep() in preference to perl's sleep as it allows millsecond increments, and may also relinguish more timeslice to the system and allow whatever process needs to complete, to complete more quickly. It is available by default on AS builds of perl, there is no need to load any extra modules to gain access to it.

    The fact that the error is occuring from totally separate API's, and also I saw some evidence that it can be related to connections made from NT to 2K machines when perl is not involved, which suggests that this may well be a system level bug or failure rather than a perl or module problem per se.

    Please come back and report your findings if you try this. Thanks.


    Examine what is said, not who speaks.
    "Efficiency is intelligent laziness." -David Dunham
    "Think for yourself!" - Abigail
    Hooray!
    Wanted!

      Hi,

      Bonus points to Tye for suspecting that it was authentication related. (see below)

      If you're interested, here's what I tried:

      I tried intially stepping through various sleeps (from 1000 ms to 10000ms) to no avail. The script still did not connect.

      I tried connecting using NET USE with the Domain Admin user and password and this did not work (though I suspect that I did something wrong with the command so we will leave that aside :)

      If I managed to successfully embed the NET USE within the script, I will post the code here.

      Finally I popped up a Command shell Running as Domain Administrator and tried the script. It connected successfully every time.

      So thanks for all your help though we are still not left with any convincing reason for the original error.

      Thanks

      Kakaze

        As I suspected, I was doing something wrong with the NET USE command.

        Here's how it should look to connect to a machine:

        $list = "net use \\\\$Machine $password /USER:$domain\\$user"; system ("$list");

        And then connect as follows: $regKey = $Registry->Connect( $Machine, $target, { Access=>KEY_READ } );

        Note that I do not do and explicit or die after the connect attempt since I want to trap the failed machines so I do an  if ($regKey) {} later in the code.

        Kakaze

Re: Win32::TieRegistry and Connect Method Errors
by meetraz (Hermit) on Nov 12, 2003 at 17:58 UTC
    I tried your code on several Win2k servers and workstations, and didn't have any problems. I suspect there are other Win32 operations going on at the same time that are causing this problem... are you using any other modules? Any threading?