How to print .txt file containing esc/pos commands using command prompt in windows? - windows

I am trying to print ESC/pos commands from the .txt file using windows command prompt.
Let me explain what I tried so far:
I have connected my Epson Tm-m30 printer. Using a virtual port driver I can print the .txt file using the following command:
print /d:COM1 'file path'
Now my question: as it is, ESC/pos printer needs to print the ESC/pos commands like a paper cut, barcode printing, etc. When I paste the ESC/pos commands in the .txt file, it is print as it is, not as ESC/pos commands.
I am trying to print The following ESC/pos commands:
\x1B\x40
\x1D(k\x0d\x00\x30\x50\x30TEST PRINT
\x1D(k\x03\x00\x30\x51\x
But while printing it is printing it looks like above, not as ESC commands.
How do I print ESC/pos commands using a .txt file?

There are no commands built into Windows by default, so the following options are possible.
Use the tools distributed by EPSON
Send Data Tool
Issuing Receipts with Barcodes
Use a free tool published by someone somewhere
Create your own with a script tool such as PowerShell
about_Special_Characters
Make your own with C++/C#/VB etc.
Regex.Unescape(String) Method
Regular Expression Language - Quick Reference
Create a file with binary data instead of text and copy it to COM1 with the copy /b command

Related

print a file in landscape from Windows command line or powershell

I can happily print a file using get-content e.g. :
get-content .\test.txt|out-printer "epson wp-4525 series"
How can I do this in landscape?
Can't help you in powershell but on the command line it is a matter of sending the correct escape code to your printer. Most printers support the HP escape sequences to do that. See eg here for a basic list. You can either echo the characters directly to your printer, insert them in your text file or send them through separate files. In the last case you can insert the code
Esc&l1O in a file, eg landscape.prn, you will need also a code to eject the page from your printer Esc&l0H. The Esc is the Ascii 27 character, you will need to save this in an editor capable of this, in notepad you need to save the file as unicode.
Copying the whole thing to your printer goes like this for a shared USB or network printer
copy /b landscape.prn+text.txt+eject.prn \\pcname\shared_printer_name
or
copy /b landscape.prn+text.txt+eject.prn lpt1
if you use a parallel printer or redirect to lpt1
The /b is to copy in binary mode making sure all characters are passed.

Using "lpr" command to print text without text file on Windows?

I can use the command to simply print an image using lpr command on windows.
However, how to use "lpr" printing a text (say "hello world") without creating a new text file everytime? It would be great if I can also dynamically set its fonts-size and name?
Thanks.

Printing a Text File from Command Prompt

Alright, this is outside my area of expertise but so here's what I'm trying to do:
→ I have a POS (Point of Sale) receipt printer. I have the drivers installed for it and can print a test page with it. I can also print from notepad++ (for example), although it leaves a lot of empty space. This printer is set as the default printer.
→ I want to be able to print a single line to the printer using some automated process in Windows. My initial thought was to have the line I wanted to print in a text file and then to use:
print C:\filename.txt
from Command Prompt. However, this results in
C:\filename.txt is currently being printed
but nothing is printed. I am unfamiliar with ESC/POS and do not understand where to incorporate those commands either. Basically, printing a txt file from Command Prompt is my first necessity though. Any help?
Try this :
START /MIN NOTEPAD /P yourfile.txt
I'd try
copy /b yourfilename yourportname
where yourportname may be PRN: or LPT1: or whatever.

controlling interactive console programs from batch file (cmd)

I have a WindowsXP console program that offers an interactive cli mode (some cisco tool) prompting for username and password. How can I programmatically pipe those in from a .bat file?
It will depend on the tool.
Hopefully the cisco tool supports command line parameters (-username=foo etc), can read commands from a pipe (echo username | tool.exe), or can accept an input file (tool.exe #input.txt).
If it gets all its input from stdin, you can create a text file containing the input in the right order and pipe it to the application. For example, create a file input.txt with this content:
myusername
mypassword
and do this so tool.exe gets its input from input.txt:
tool.exe < input.txt
But once again it depends on the tool.
Failing those easy answers, the next option is sending keystrokes to the cmd window, using jscript, vbscript or some other language. See automate a windows command line utility with a batch file - send keystrokes to std input after utility starts.
I had the same problems, but none of the listed solutions worked.
I tried different things and the following worked for me:
Command.exe "First Interactive choice" "Second one" "Third"

Print Txt file from Processing Sketch

I have a processing sketch that sends a String to a .txt file and then I want to be able to print the same .txt file from the processing sketch.
Any ideas on how to do this?
I've thought about running a .bat file from the processing sketch using open() but my shell scripting skills are non-existent.
Thanks!
On windows:
Your idea about opening a console to do the work, since this is platform stuff, seems reasonable. However, if you have a USB printer it's tough.
Instead, I suggest you install Powershell (on Windows 7 you have it by default). The way you can print in Powershell is to get the contents of a file and shoot it to the Out-Printer (alias 'lp') cmdlet. Then your open call is:
String psPrint = "C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe -Command \"Get-Content " + filename + " | Out-Printer\"";
open(psPrint);
N.B. I haven't tried this in Processing, but the command line works for me.

Resources