Search code examples
command-linebatch-filewindows-vista

how to get an actively refreshing tasklist in command line (windows vista)


How do i get the tasklist command to refresh over a period of time? Is there any way to do so? Any advice would be greatly appreciated. BTW i would prefer not having to download any outside command line tools. :) Thank you in advance for your replies.


Solution

  • You may use anyone of the multiple methods previously posted here (search for "delay"). For example:

    @ECHO OFF
    :REFRESH
    
    ECHO Put your Tasklist command here...
    
    REM DELAY 20 seconds
    
    REM GET ENDING SECOND
    FOR /F "TOKENS=1-3 DELIMS=:." %%A IN ("%TIME%") DO SET /A H=%%A, M=1%%B%%100, S=1%%C%%100, ENDING=(H*60+M)*60+S+20
    
    REM WAIT FOR SUCH A SECOND
    :WAIT
    FOR /F "TOKENS=1-3 DELIMS=:." %%A IN ("%TIME%") DO SET /A H=%%A, M=1%%B%%100, S=1%%C%%100, CURRENT=(H*60+M)*60+S
    IF %CURRENT% LSS %ENDING% GOTO WAIT
    
    GOTO REFRESH
    

    Perhaps you may want to start this Batch file with low priority to not consume too much CPU time this way:

    START "Tasklist Monitor" /LOW TheBatchFile