I'd suggest you change
FOR /F "tokens=*" %%I in (list.txt) do call :pinger %%I goto :eof
:eof
move %txt% 1e-client
exit
to
FOR /F "tokens=*" %%I in (list.txt) do call :pinger %%I
move %txt% 1e-client
exit
because :eof
is a special label meaning 'end of file`. It should not be assigned in a batchfile.
Also - it appears to have no purpose where it is. If you had coded
FOR /F "tokens=*" %%I in (list.txt) do call :pinger %%I&goto :eof
then the batch should have terminated after processing the first line in list.txt
. As it stands, goto
should merely have become an unused second parameter to :pinger
and :eof
an unused third parameter.
Personally, I only ever use goto label
(no colon) except for goto :eof
(the special condition) to avoid this very problem.
I believe the actual cause of your problem is here:
Echo Online: %pingstatus% >> %txt%
wmic /node:%1 /output:c:\tmp.txt product get name,version |findstr /c:"1E NomadBranch" c:\tmp.txt > %txt%
ping 1.1.1.1 -n 1 -w 100 >nul
This will echo whatever to the txt
file, then run wmic and send its output to c:\temp.txt
(since you specify /output
) and send the screen output to findstr, which appears also to be reading c:\temp.txt
which is probably open at the time... and to cap it all off, you are then redirecting the findstr
output to a new txt
(since you are using the create new
redirector, >
, not the append
redirector, >>
.
I'd suggest
Echo Online: %pingstatus% >> %txt%
wmic /node:%1 /output:c:\tmp.txt product get name,version
findstr /c:"1E NomadBranch" c:\tmp.txt >> %txt%
ping 1.1.1.1 -n 1 -w 100 >nul
... but I'll admit having not tested that.