echo %time% duplicate outputs
Solution 1:
CMD expands variables and then executes each line. That means that
echo %time% & ping 127.0.0.1 & echo %time%
is first expanded, and then executed
There is also "delayed expansion" Here is some example usage, and even more detailed This however only works in a cmd file, and not on commandline
setlocal ENABLEDELAYEDEXPANSION
echo !time! & ping 127.0.0.1 & echo !time!
Continue searching maybe cmd /V can be used:
cmd /V /C "echo %time% & ping 127.0.0.1 & echo !time!"
It gives expected result for me, but there might be gotchas preventing some use cases.