0

Edit: I did not realize you had to use escapes within echo commands. After looking at the linked duplicate answer and the answers to this question, I have fixed my issue by using escapes on the > and |. I also implemented @Mofi's suggestion which was to remove the == from the ERRORLEVEL statements. Thank you all so much for your suggestions and advice! The corrected code is:

@ECHO OFF
ECHO ====================================================
ECHO \    _______           __ __                       /
ECHO /   /_  __(_)_ _  ___ / //_/__ ___ ___  ___ ____   \
ECHO \    / / / /  ' \/ -_) ,^< / -_) -_) _ \/ -_) __/   /
ECHO /   /_/ /_/_/_/_/\__/_/^|_^|\__/\__/ .__/\__/_/      \
ECHO \                               /_/                /
ECHO /                 Choose an Option:                \
ECHO \                   Clock [I]n                     /
ECHO /                   Clock [O]ut                    \
ECHO \              [S]ee Previous Times                /
ECHO /                                                  \
ECHO \                                                  /
ECHO /                                                  \
ECHO \                                                  /
ECHO /                                                  \
ECHO ====================================================/
CHOICE /c IOS /N
IF ERRORLEVEL 3 goto :Times
IF ERRORLEVEL 2 goto :Out
IF ERRORLEVEL 1 goto :In

Original Question:

I'm making a file called "TimeKeeper" and I wanted it to look cool so I had it print timekeeper in ASCII art style. But every time I run the script is errors out after echoing the first four lines and says:

Access is denied.
'_' is not recognized as an internal or external command, operable program or batch file.

The thing that confuses me is I'm using echo to output the ASCII and it seems to be formatted properly. I'm encoding in ANSII and have no other encoding formats in the file

Code:

@ECHO OFF
ECHO ====================================================
ECHO \    _______           __ __                       /
ECHO /   /_  __(_)_ _  ___ / //_/__ ___ ___  ___ ____   \
ECHO \    / / / /  ' \/ -_) ,< / -_) -_) _ \/ -_) __/   /
ECHO /   /_/ /_/_/_/_/\__/_/|_|\__/\__/ .__/\__/_/      \
ECHO \                               /_/                /
ECHO /                 Choose an Option:                \
ECHO \                   Clock [I]n                     /
ECHO /                   Clock [O]ut                    \
ECHO \              [S]ee Previous Times                /
ECHO /                                                  \
ECHO \                                                  /
ECHO /                                                  \
ECHO \                                                  /
ECHO /                                                  \
ECHO ====================================================
CHOICE /c IOS /N
IF ERRORLEVEL == 3 goto :Times
IF ERRORLEVEL == 2 goto :Out
IF ERRORLEVEL == 1 goto :In

It doesn't even get to the choice prompt before it closes due to the error. This basically halts the entire program so I'm stuck, any advice or suggestions helps a ton!

Excallypurr
  • 319
  • 1
  • 16
  • 5
    Some chars have a special meaning in batch. For example `|` and `<`. To literally echo them, you have to escape them: `echo ^|_^<` – Stephan Jun 13 '18 at 17:02
  • @Excallypurr, as part of your edit, it would be advised to also update the provided code to match the fixes you've stated that you've now made to it. Although if you're not reporting any updated issue, I'd suggest you roll back the edit and provide your final code as an answer. That said if your answer doesn't improve on the one you've already accepted, do neither, leave the question as it was and don't post an answer at all. – Compo Jun 13 '18 at 22:38

1 Answers1

2

There are some characters in batch files that will be interpreted no matter where you put them (even inside text outputs).

For instance, | and ( have special meanings, they could be displayed by "escaping" them this way : ^| and ^(.

In case you have other troubles with special characters, here's a list of those, and the way you should escape them when displaying text :

http://www.robvanderwoude.com/escapechars.php

Antoine Pelletier
  • 3,164
  • 3
  • 40
  • 62