Solved

Problem with echo of escape codes in batch file

Posted on 2000-04-17
5
1,669 Views
Last Modified: 2013-12-21
The following line in a batch file works in Win98 but not in WinNT.

echo &l0O&l8D(s12H >> TEST.UTV

The first character after the echo is the Escape character (ascii 27).
The purpose is to add some printer-format codes to a file to switch from portrait to landscape, but on WinNT I get the response:

The name specified is not recognized as an internal or external command.

0
Comment
Question by:hansbos
  • 2
  • 2
5 Comments
 
LVL 2

Expert Comment

by:percy_k
ID: 2722217
Try this

echo ^[^&l0O^[^&l8D^[(s12H >> TEST.UTV

Percy
0
 

Author Comment

by:hansbos
ID: 2725847
Percy,

Thanks for your comment. I tried your command but I didn't get the escape codes in the file.
I already made a bypass by using the type command in combination with a file with the printer codes, but I was just curious if there was a way to echo the escape codes.

Hans
0
 
LVL 2

Accepted Solution

by:
percy_k earned 200 total points
ID: 2726096
Hans,

The error you got is come from the character "&" which will confused the system to assume the echo is end and submit the command next to "&"

Add a "^" in front of the "&" can drive the system to recongize "&" as character.

I try this in my machine and can generated a test file with the script you want. Please tell the detail of the error.

Anyway, if you want to echo a "&" to a script. You must add a character "^" in front of it. "^"= ctrl-6

percy
0
 
LVL 23

Expert Comment

by:Tim Holman
ID: 2726253
NT doesn't provide ANSI support (flashy escape codes) in its command line.
However, you could configure autoexec.nt / config.nt to include the ANSI driver, open a DOS session, and then use escape codes to send to your printer.
0
 

Author Comment

by:hansbos
ID: 2726273
Percy,

Thanks. The "^"-character worked.

Hans
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

The use of stolen credentials is a hot commodity this year allowing threat actors to move laterally within the network in order to avoid breach detection.
Sometimes drives fill up and we don't know why.  If you don't understand the best way to use the tools available, you may end up being stumped as to why your drive says it's not full when you have no space left!  Here's how you can find out...
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now