2

I'm looking for a good workaround to do this on Windows 7 and Windows XP:

  • Disable or make ineffective the network interface (ETH, WIFI, any NIC).
  • If the user connect his ETH cable, the network interface enable again.

Important Notes to take care:

  • I'm working with wmic on Win7 (through the command line)
  • I'm working with devcon on WinXP (through the command line)
  • I'm specifically working with the .NET Framework 2.0 on C# but this is just for informational purposes.
  • I know that an event won't help me to detect it (if there is a way or workaround to do this I don't know it).

The real problem is that when I disable the NIC, I can't know if the user connects his cable or has a wired network. This is why I am looking for a workaround.

I'll treat suggestions as answers if no direct answer exists. I'll provide any extra detail necessary.

Leandro Bardelli
  • 213
  • 4
  • 15

1 Answers1

1

Can't be done. Once the interface is disabled Windows cannot see when a cable has been plugged in. It needs the interface enabled in order to talk to it and get the information about whether or not it has network connectivity. Your best et is to see if you can finnd a way to leave the interface enabled but not available at the application level, then enable that level when there is connectivity. This is of course a programming issue and not appropriate for SF.

John Gardeniers
  • 27,458
  • 12
  • 55
  • 109
  • can be done changing the properties of the nic, for example, giving a bad-routing or a gateway to a inexistent network router or something about? For example gateway to 127.0.0.1 or 0.0.0.0 ? – Leandro Bardelli May 30 '12 at 13:17
  • @Leandro, you're confusing disabling a NIC (as per your question) with simply making it ineffective (as per your comment). Which do you want? – John Gardeniers May 30 '12 at 13:20
  • First of all, avoid a user connects to more than one nic and that if wired is avaible, the user can not connect and disconnect from the wifi – Leandro Bardelli Jun 06 '12 at 00:09
  • 1
    @Leandro, in that case you should reword your question because you only need the interface to be ineffective, not disabled. This might be a language issue but the difference is significant and changed the question completely. – John Gardeniers Jun 06 '12 at 00:18
  • Well that is possible on XP and Win7? There is a way to switch off without disable it? That's the reason I wrote: if there is a way or workaround to do this I don't know it – Leandro Bardelli Jun 06 '12 at 00:55