WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Registry
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Problem Closing RegConnect Connections Using WntCancelCon


Question:

The help screens for RegConnect explain that the session opened by this function is not closed by simply running RegCloseKey(). It advises to run wntCancelCon() pointing to the IPC$ share on the remote workstation. When I try to run that in my Windows 2000 environment, I get the error: 512 Device not currently connected. Note: I am using RegConnect in a For loop.

Has anyone else tried to read remote registries using RegConnect and tried to close these connections? When I disable this line in my script, the program stops connecting to remote workstations at some point and notes that all future remote registries are unreachable. I figure I am filling a connection table somewhere, but my attempts to clear my connections are not working.

I tried using persist @TRUE and @FALSE, but got the same result. Any help is appreciated.

Answer:

The documentation should be corrected to clarify that wntCancelCon() is only needed when you've explicitly connected to the IPC$ share (like using wntAddDrive).

When you access a remote workstation, you have to be logged on to a domain account that is in the same domain as the remote workstation, or is in a domain that is trusted by the remote workstation's domain. Lacking that, you need to be logged on to a user account that has the exact same username & password as an account on the remote workstation. Finally, if you fail to meet any of the previously mentioned requirements, you need to supply specific user credentials when connecting to the remote workstation such that the credentials are for a local account on the remote workstation.

If you've recently connected to remote system for print, file or registry access, and then suddenly desire to access that system as a different user. In that case, any explicitly connected shares must be disconnected and you have to wait for Windows to timeout & tear down the connection in the background before you can explicitly connect to the IPC$ share using a specific set of credentials. It is that timeout period that comes into play and throws a spanner in the works. You may wan to add a small TimeDelay within the For loop to help give the system time to tear down each connection.

User Reply:

I removed wntCancelCon and added a timedelay and now I can sucessfully connect and disconnect to over 5000 machines.
Article ID:   W16668
File Created: 2005:02:18:12:21:50
Last Updated: 2005:02:18:12:21:50