Microsoft KB Archive/828807

= Error when you programmatically remove and then reinstall Internet Connection Sharing in Windows XP =

Article ID: 828807

Article Last Modified on 6/5/2007

-

APPLIES TO


 * Microsoft Windows XP Home Edition
 * Microsoft Windows XP Professional

-





SYMPTOMS
When you use a custom program to programmatically remove and then reinstall Internet Connection Sharing on a computer that has more than one network adapter, you may receive the following error message:

An event was unable to invoke any of the subscribers. Code: 80040201



CAUSE
This issue occurs because Microsoft Windows XP saves the Internet Connection Sharing state for connections that are not currently present on the computer. This action means that users do not have to reconfigure their network connection properties every time they remove and reconnect a networking device. However, Windows XP returns an error when the custom program tries to change the Internet Connection Sharing state of network interfaces that are not currently present.



WORKAROUND
Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements. The following code is not a substitute for the DisableSharing and EnableSharing methods. The following code is just a workaround to use those methods when an exceptional condition (such as the NIC no longer being present) occurs.

In your code, call DisableSharing before you call EnableSharing. If you receive the 80040201 error while you are calling EnableSharing for the private interface, the error should be caught and you can use the following sample code to recover from it. The sample code is written in VBScript. However, you can use any language that can access Windows Management Instrumentation (WMI) to complete these steps: Set Service = GetObject(&quot;winmgmts:{impersonationLevel=impersonate}!root/Microsoft/HomeNet&quot;) Set enumset = Service.InstancesOf(&quot;HNet_ConnectionProperties&quot;)

for each Instance in enumSet

if Instance.IsIcsPrivate = true then Instance.IsIcsPrivate = false Instance.put_ end if

Next After you run this code, call DisableSharing before you start over with the EnableSharing method.

If you receive the 80040201 error while calling EnableSharing for the public interface, run the code again, except replace IsIcsPrivate with IsIcsPublic. Call DisableSharing again before you start over with the EnableSharing method.

The EnableSharing and DisableSharing methods do more than just toggle the two flags that this article mentions. If the process of enabling sharing is interrupted, you must call DisableSharing be called before you start over.



STATUS
Microsoft is researching this problem and will post more information in this article when the information becomes available.

Additional query words: com com+

Keywords: kberrmsg kbprb KB828807

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.