title: How can I determine if a computer is connected to Ethernet or Wifi in cmd?
body: <p>I have a Python script which runs via a shared server.  The speed at which this script runs directly relates to the user's connection speed.  In our office, the Wifi is miserably slow, so trying to run this script is very slow.  Many users interpret the lag between starting the script and it actually showing to be a failure to start, so they try to open it again.</p>
  
  <p>I would like a warning box to show if the user is connected to Wifi rather than ethernet.  I know I can determine this manually by checking <code>ipconfig</code>, but I'd like to do it in the batch file that runs my script.  </p>
  
  <p>How can I determine if a computer is connected to Ethernet or Wifi?</p>
  
  <p>Here's what I have so far:</p>
  
  <pre><code>CHECK IF WIFI
  
  if WifiIsOn (
    echo set WshShell = WScript.CreateObject("WScript.Shell") &gt; %tmp%\tmp.vbs
    echo WScript.Quit (WshShell.Popup( "You are connected to wifi, this may slow the execution of the program and cause bugs!" ,10 ,"Wifi Warning", 6)) &gt;&gt; %tmp%\tmp.vbs
    cscript /nologo %tmp%\tmp.vbs
    if %errorlevel%==11 (
      del %tmp%\tmp.vbs
      start script
    ) 
  
    if %errorlevel%==4 (
      RECHECK WIFI
    )
  
    if %errorlevel%==2 (
      del %tmp%\tmp.vbs
    )
  ) else (
     start script
  )
  </code></pre>
  
  <p>For the curious, I got how to do the dialog from James K's answer <a href="https://stackoverflow.com/questions/12514475/how-can-you-create-pop-up-messages-in-a-batch-script">here</a></p>
  
  <p><strong>EDIT:</strong> Here's what <code>ipconfig</code> shows:</p>
  
  <pre><code>Windows IP Configuration
  
  
  Wireless LAN adapter Wireless Network Connection 2:
  
     Media State . . . . . . . . . . . : Media disconnected
     Connection-specific DNS Suffix  . :
  
  Ethernet adapter Bluetooth Network Connection:
  
     Media State . . . . . . . . . . . : Media disconnected
     Connection-specific DNS Suffix  . :
  
  Wireless LAN adapter Wireless Network Connection:
  
     Connection-specific DNS Suffix  . : stuff
     Link-local IPv6 Address . . . . . : stuff
     IPv4 Address. . . . . . . . . . . : stuff
     Subnet Mask . . . . . . . . . . . : stuff
     Default Gateway . . . . . . . . . : stuff
  
  Ethernet adapter Local Area Connection:
  
     Connection-specific DNS Suffix  . : stuff
     Link-local IPv6 Address . . . . . : stuff
     IPv4 Address. . . . . . . . . . . : stuff
     Subnet Mask . . . . . . . . . . . : stuff
     Default Gateway . . . . . . . . . : stuff
  
  Tunnel adapter isatap.stuff:
  
     Media State . . . . . . . . . . . : Media disconnected
     Connection-specific DNS Suffix  . : stuff
  
  Tunnel adapter Local Area Connection* 13:
  
     Media State . . . . . . . . . . . : Media disconnected
     Connection-specific DNS Suffix  . :
  
  Tunnel adapter isatap.{stuff}:
  
     Media State . . . . . . . . . . . : Media disconnected
     Connection-specific DNS Suffix  . :
  
  Tunnel adapter isatap.{stuff}:
  
     Media State . . . . . . . . . . . : Media disconnected
     Connection-specific DNS Suffix  . :
  </code></pre>