My USB network adapter (latest drivers) disappear from "network connections" window in control panel when computer wake up from sleep. So construct batch file to resetting adapter using devcon. After adapter reset I want to add some IP subnets programatically using netsh. Problem is the adapter probably need some time after reset (disable && enable commands) is performed, because netsh failed if started earlier than some (let say 6 seconds, old Atom CPU is used) time. Now I have inserted timeout using 'timeout /T' command but this time could vary by system load. Question is: Is there any way to detect adapter status programatically from batch file?
set "netcmd=netsh in ip add address ETH1 192.168.0.100 255.255.255.0"
devcon disable "USB\VID_9710&PID_7830" >NUL
devcon enable "USB\VID_9710&PID_7830" >NUL
timeout /T 6 >NUL
%netcmd%
netsh interface show interface name="Local Area Connection"
shows something like :You can check it's state with:
Same can be done with
...find "Administrative state" |find "Enabled" ...
(depends on which adapter status you refer to)NOTE: change
Local Area Connection
to the name of your adapter