2

I had just showed a friend of mine some of the cool stuff you can do with the command prompt and batch code and she gotten really interested and wants to try it out on her own when she has the time. Shortly after that, I had gotten the idea of making a nice, well polished batch file that will not only demonstrate, but also display display the code in the code on the command window with out the command window executing the commands.

Example: the code in question, %date%, will display the current date when I have the code of echo %date% on the line. I would like to have %date% to be displayed like normal text.

What code am I missing to have %date% and %time% and any other batch code be displayed as normal text so the person having fun with the file can see the code without having to cipher through the code to find the code I am wanting them to learn?

P.S.

I have a feeling this question might have been answer through a different thread and if so, fee free to link me to it. Thank you!

8
  • 7
    You need to escape percent symbols with percent symbols. echo %%date%%. Commented Dec 23, 2019 at 18:57
  • 2
    just because you will probably need it soon: the escape character for most other "poison characters" (chars that have a special meaning in cmd) is a caret ^: echo ^&^<^>^| Commented Dec 23, 2019 at 19:35
  • 1
    For the sake of completeness: in command prompt the %-escaping by doubling does not work, so you need to do echo %^date% to literally return %date% (given that no variable %^date% is defined)... Commented Dec 23, 2019 at 19:58
  • 1
    The underlying question however, is why would somebody want to learn code from somebody, who themselves don't know how to code the code they're trying to teach? Commented Dec 23, 2019 at 20:36
  • 2
    Delete the first line echo off. Commented Dec 23, 2019 at 22:39

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.