Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I disable at application level a network interface?

The main question is this:

If I disable the nic trough wmic (win7) or devcon (XP), the "plug and play" of a wired nic doesn't work any more. For example, if the user put the cable on a disabled nic, the OS doesn't know about it.

So I need to persist the enable condition but disabling the networking like a disable nic.

There's some API, network configuration (routing, changing ip, changing gateway, any), .NET Framework resource (Only NetFramework 2.0) or do you can think in any workaround to do this?

Suggest and ideas also will be treated as a solution.

Thanks and kind regards.

Edit: The why:

I'm doing an application required by a third part company for resolve a non-responsable people issue.

The main idea of the application is automatically "disable" (so far don't think by 'disable' is disabling the nic), so automatically "disable" a selected wired.

But in some conditions, for example a DNS shutdown or something like, if the user plugs the utp cable on the eth, the app needs to know if is wired, to up the nic.

The application has a workflow oriented to "don't be a fool" behavior. So we need take care about all conditions, for experts users or newbies.

Suppose this case:

nic A is enabled and up. nic B is enabled and down.

User connects cable B.

nic B is enabled and up.

Application disables connection B.

nic B is disabled.

User disconnects cable B.

nic A is enabled, up but doesn't have internet connection. (For third-company is a "down" case)

App disables nic A.

App can NOT enable nic B when users reconnects cable B.

So far, there is a lots of combinations.

share|improve this question
Can you tell us more about what you are trying to do? At the moment it sounds like you are trying to create some kind of Schrödinger's cat state where the nic is in a superposition of both enabled and disabled states. – Zoredache May 31 '12 at 17:07
Yeah I know, it sounds like that! lol. – Leandro Tupone May 31 '12 at 17:27
I'm thinking in a "disable" state that not disable the nic. – Leandro Tupone May 31 '12 at 17:27
up vote 1 down vote accepted

You could set the NIC to not pull its address from DHCP and its IP to an invalid address.

You could disable the TCP/IP protocol for that adapter by unchecking the box next to it from the network adapter properties in ncpa.cpl

share|improve this answer
good approach. Do you know if can i do it trough command line? That option has a reference name to google it or something? – Leandro Tupone May 31 '12 at 20:33
netsh interface something or other ... will update if I have time later ... – LawrenceC May 31 '12 at 20:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .