Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

how to detect the network interface is "initialized"

18 views
Skip to first unread message

Petr Laznovsky

unread,
Dec 15, 2017, 9:01:03 AM12/15/17
to
My USB network adapter (newest drivers) is not presented in system after computer wake-up from
sleep. Few persons working on this machine, including changing IP addresses (due to attaching and
working with various network devices).

When I go to computer, wake it up and want to start working immediatelly, but now I need to reset
(enable && disable) interface, check ip networks and possibly add some if missing. This is boring so
I construct script which reset interface and add required addresses if missing.

Problem is the interface need some time to "initialization" (add all static defined networks) so I
insert timeout command, but this time could vary by cpu load and I want to check if interface is
already "initilizated" programatically, but have no idea how.

Second problem is the checking if IP network is already listed or should be added does not working.

Any ideas? L.




set "__net1=netsh in ip add address ETH1 192.168.0.100 255.255.255.0"
set "__net2=netsh in ip add address ETH1 192.168.1.100 255.255.255.0"
set "__net3=netsh in ip add address ETH1 192.168.2.100 255.255.255.0"
set "__net4=netsh in ip add address ETH1 192.168.2.100 255.255.255.0"
set "__net5=netsh in ip add address ETH1 192.168.168.100 255.255.255.0"
devcon disable "USB\VID_9710&PID_7830" >NUL
devcon enable "USB\VID_9710&PID_7830" >NUL

timeout /T 6 /NOBREAK

@echo off & setlocal ENABLEDELAYEDEXPANSION
for /f "tokens=2 delims=:" %%a in ('ipconfig ^| findstr /C:"IPv4 Address"') do (
set "string="
for /f "tokens=2 delims==" %%A in ('set __net') do (
echo %%~A| findstr "%%~a">NUL
if not errorlevel 1 set "string=%%~A"
)
if not "!string!"=="" !string!
)

JJ

unread,
Dec 16, 2017, 5:33:48 AM12/16/17
to
IMO, the program load time for NETSH is pretty high. I'd suggest using PING
instead.
0 new messages