Greetings for the day !!
I'm a newbie to this forum, just trying to get help from experts to fix my below code.
I'm trying to get all running automatic services and display 25 lines per window, my if loop not actually not going to next even after the counter %plcnt% has a -ve value, could any one help to fix this, it will be a great help.
Code: Select all
:: CODE
::
@ECHO OFF
set slcnt=1
set elcnt=25
set file=c:\tmp\tmp_file.txt
:loop
ECHO ________________________________________________________________________
ECHO HOST NAME: %computername%
ECHO DATE STAMP: %time:~-11,2%:%time:~-8,2% %date%
ECHO ========================================================================
ECHO SYSTEM RUNNING AUTO SERVICES STATUS
ECHO ========================================================================
WMIC SERVICE GET name,StartMode,State,Status | FINDSTR "Auto" | FINDSTR /V "Manual Stopped" > %file% && for /l %%l in (%slcnt%,1,%elcnt%) do @for /f "tokens=1,2* delims=:" %%a in ('findstr /n /r "^" %file% ^| findstr /r "^%%l:"') do @echo %%b
ECHO __________________________LINE %slcnt% TO %elcnt%________________________________
TIMEOUT 3 > NUL
CLS
:: FIND TOTAL AND PENDING LINE COUNT
set /a tlcnt=0
for /f %%a in ('type "%file%"^|find "" /v /c') do set /a tlcnt=%%a
::
set /a plcnt= %tlcnt% - %elcnt%
::
:: IF PENDING LINE COUNT GREATER THAN OR EQUAL TO 0 THEN LOOP
::
IF /i %plcnt% GEQ "0" (
set slcnt=%elcnt%
set /a elcnt=25 + %elcnt%
GOTO :loop
) ELSE (
::
GOTO :next
)
::
:next
ECHO NEXT COMMAND
::
:EOF
Thanks in Advance to all Batch Guru's