title: Programmatically retrieve disconnected network adapter information in .NET
body: <p>I have an application written in C# that needs to retrieve information like IP address, subnet mask from a disconnected network adapter.</p>
  
  <p>I've tried using various methods such as WMI and the .NET NetworkAdapter class but they don't return any useful data when the network adapter is disconnected. I'm pretty sure Windows keeps this information somewhere, since I can apply network settings using netsh and it appears correctly in the Control Panel.</p>
  
  <p>One thing that worked for me in XP was to parse the output of the <code>netsh</code> tool and it would return information even for a disconnected adapter. However, this doesn't seem to work on Windows 7.</p>
  
  <p>Win XP output:</p>
  
  <pre><code>Configuration for interface "Local Area Connection 5"
      DHCP enabled:                         No
      IP Address:                           169.254.0.128
      SubnetMask:                           255.255.255.0
      InterfaceMetric:                      0
  </code></pre>
  
  <p>Win7 output:</p>
  
  <pre><code>Configuration for interface "Local Area Connection 2"
      DHCP enabled:                         No
      InterfaceMetric:                      5
  </code></pre>
  
  <p>Any ideas?</p>