|might try it with these mod.s. I'm not sure exactly what your requirements / objectives are, so i might have misconstrued some interpretations, but this is my "take" on it thus far.|
:: this loads an array, but count never seems to have more than one line anyway?
:for /f "tokens=* delims= " %%a in (count.txt) do (
:set /a N+=1
:: you could substitute the foll. for above 3 lines, to de-complicate:
set /p counter=<count.txt
For /f %%A in ('devcon find "USB\VID_0781*"') do (
if %%A==No (set /a counter+=1) else (set /a counter = 0)
:: echo out, regardless if its 0,1 or 2 ?
> count.txt echo %counter%
:: note that: echo %counter% > count.txt will include a trailing space!
echo %date% %time% >> log.txt
devcon find hwids USB\VID_0781* >> log.txt
if !counter! geq 2 (start error.vbs)