Batch files…still around

11th April 2021

i used to use a program from the M$ powertools called sleep.exe but recently i found a native solution. A ping to the loopback address takes a known amount of time and takes slightly less processing power than the old sleep.exe util. credit source

ping -n 120 127.0.0.1 1>nul

I use this in my redo.bat that i now have memorized

:start
%1 %2 %3 %4 %5 %6 %7 %8 %9
ping -n 120 127.0.0.1 1>nul
goto start

this was originally conceived because ping fills the screen and is impossible to tell if it’s still scrolling or its paused. but i found it useful for many other things.

for sending email from scripts blat.exe has been replaced with mailsend-go Even tho it hates Gmail it works fine with M$.

Following is an example that sends me memory stats from an old snowflake server. I still need a little help with the tail command, but i didn’t use too many brain cycles on this.

set logfile=c:\share\hitask.log
echo “==============================================================” >> %logfile%
echo “==============================================================” >> %logfile%
date /t >> %logfile%
wmic OS get FreePhysicalMemory >> %logfile%
tasklist /FI “MEMUSAGE gt 100000” >> %logfile%

rem make sure the log file doesn’t grow too large, grrr doesn’t work right
: c:\share\tail -200 %logfile% > tmp%logfile%
: copy tmp%logfile% %logfile% -Y

c:\share\mailsend-go -sub “VHG Term Svr Memory Report” -smtp smtp.office365.com -port 587 auth -user me@office.com -pass “ILikePie” -from “me@office.com” -to “me@office.com” -from “me@office.com” body -msg “A log file is attached” attach -file “c:\share\hitask.log”

Example output:

sry too many NUL characters in DOS output