Solved

Problem with echo of escape codes in batch file

Posted on 2000-04-17
5
1,653 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
Comment Utility
Try this

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

Percy
0
 

Author Comment

by:hansbos
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Percy,

Thanks. The "^"-character worked.

Hans
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

This is an article about Leadership and accepting and adapting to new challenges. It focuses mostly on upgrading to Windows 10.
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 create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

743 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

19 Experts available now in Live!

Get 1:1 Help Now