Re: Enable/ disable a LAN connection

From: Willy Denoyette [MVP] (willy.denoyette_at_pandora.be)
Date: 01/15/05


Date: Sat, 15 Jan 2005 18:08:44 +0100

Win32_NetworkConnection ConnectionState is read-only. You can't change it's
state.
Only thing you can do using WMI is unloading/loading the device driver for
you connection (exactly as the Control pannel Connections applet does when
disabling/enabling).

Willy.

"Brian Brown" <BrianBrown@discussions.microsoft.com> wrote in message
news:BEEB2AE8-6DF0-4960-8402-837315D66222@microsoft.com...
>I know of a couple of ways to do this. One is to use interop calling
> WNetCancelConnection2 (see links below) or you can use the WMI class
> Win32_NetworkConnection and use the ConnectionState property to
> disconnected
> to turn it off.
>
> I hope this helps
> --------------------
> interop links
> http://www.pinvoke.net
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wnet/wnet/canceling_a_network_connection.asp
>
> WMI link
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/win32_networkconnection.asp
>