2

I'm stuck trying to print a custom command execution time. If I try to do something like this:

echo %time% & START "TestAgente" /W systeminfo  & echo %time%

I got same begin and end time:

enter image description here

I have tried with some combinations playing with delayed-expansion, but I think it fails (I guess) because in running 3 commands in a line instead of batch file.

Does anyone done something like this (without PowerShell). It has to be a single command line that someone could copy, paste and execute.

5
  • 1
    duplicate - even with the correct one-line-syntax. Commented Oct 5, 2018 at 16:23
  • I read that before posting, but I couldn't find a proper answer for my problem, sorry. Could you please tell me what's the proper way to fix it in a single line without using power shell? Commented Oct 5, 2018 at 17:08
  • Yes, answer was there. Sorry for duplicate. Commented Oct 5, 2018 at 17:15
  • 1
    cmd /v:on /c "echo !TIME! & timeout 5 & echo !TIME!" - by Nathan Herring. Commented Oct 5, 2018 at 17:17
  • Possible duplicate of How do I measure execution time of a command on the Windows command line? Commented Oct 6, 2018 at 15:46

1 Answer 1

1

Like @Stephan said, the right way was in that post, and it worked!!

cmd /v:on /c "echo !time! & START "TestAgente" /W systeminfo & echo !time!"
Sign up to request clarification or add additional context in comments.

1 Comment

Note: Start opens another cmd instance, which needs time, which gives you (slightly) wrong results. More accurate: cmd /v:on /c "echo !time! & systeminfo & echo !time!"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.