Print time in a batch file (milliseconds)

后端 未结 7 898
野性不改
野性不改 2020-12-13 23:56

How do I print the time (in ms) in a Windows batch file?

I want to measure the time that passes between lines in my batch file, but Windows\'s \"time /T\" does not p

7条回答
  •  天命终不由人
    2020-12-14 00:17

    If you're doing something like

    for /l %%i in (1,1,500) do @echo %time%
    

    or

    if foo (
        echo %time%
        do_something
        echo %time%
    )
    

    then you could simply put a setlocal enabledelayedexpansion at the beginning of your batch file and use !time! instead of %time% which gets evaluated on execution, not on parsing the line (which includes complete blocks enclosed in parentheses).

提交回复
热议问题