When running this batch script the results are always the same. I believe I am missing something in the syntax. What am I missing?
@echo off
netstat -an | find /C "LIST" > tmpFile
set test=<tmpFile
del tmpFile
set max=6
IF !%test! GTR !max! echo Greater than X
IF !%test! LEQ !max! echo Less than X
PAUSE
:EOF
You need:
%at variabletest/Pinsetcommand for variabletestsetlocal EnableDelayedExpansion. See also Batch File: Fails to Echo Variable Inside Loop