Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Problem with echo of escape codes in batch file

Posted on 2000-04-17
5
Medium Priority
?
1,746 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 800 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

[Webinar] Cloud Security

In this webinar you will learn:

-Why existing firewall and DMZ architectures are not suited for securing cloud applications
-How to make your enterprise “Cloud Ready”, and fix your aging DMZ architecture
-How to transform your enterprise and become a Cloud Enabler

Question has a verified solution.

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

Windows 10 Creator Update has just been released and I have it working very well on my laptop. Read below for issues, fixes and ideas.
Unable to change the program that handles the scan event from a network attached Canon/Brother printer/scanner. This means you'll always have to choose which program handles this action, e.g. ControlCenter4 (in the case of a Brother).
The Task Scheduler is a powerful tool that is built into Windows. It allows you to schedule tasks (actions) on a recurring basis, such as hourly, daily, weekly, monthly, at log on, at startup, on idle, etc. This video Micro Tutorial is a brief intro…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

916 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