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.
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 ipconfig
, but I'd like to do it in the batch file that runs my script.
How can I determine if a computer is connected to Ethernet or Wifi?
Here's what I have so far:
CHECK IF WIFI
if WifiIsOn (
echo set WshShell = WScript.CreateObject("WScript.Shell") > %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)) >> %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
)
For the curious, I got how to do the dialog from James K's answer here
EDIT: Here's what ipconfig
shows:
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 . :