Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question
    
Thanks WesleyDavid for your corrections –  Leandro May 30 '12 at 4:40
add comment

1 Answer

up vote 1 down vote accepted

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.

share|improve this answer
    
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 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 Jun 6 '12 at 0: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 6 '12 at 0: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 Jun 6 '12 at 0:55
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.