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.
Related
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
No matter what my code is, even if my batch file is syntactically incorrect, even if it is absolutely correct and even if there is nothing to display on the screen the batch file when executed just displays the code as it is.
I read a similar question MSDOS prints the whole batch file on screen instead of executing but since that was on MS-DOS I hoped my issue could have a solution different than that.
Eg,
#echo off
set abcd=4
Even its batch file would just display the same lines as it is.
Please help.
Try "resetting" cmd if possible. U can try copying someone else's "cmd.exe" and replace it with yours using another bootable OS as windows wont allow that.
Here use my cmd.exe. https://drive.google.com/open?id=0B6ghonMKBfUSLVpRV0U5bG5pQTQ
Just in case u need to know I am using Windows 10 64 bit.
Check the file with an editor that allows you to see the encoding.
For example Notepad++ , you will see is very different the end of line via CF (\r) and LF (\n)
Your CMD can be recognizing EOL via \n only.
To determine whether your issue is really with line breaks being converted by your text editor (as the post you mention suggests), perform the following test:
Open a Command Line Window
Type the following command: copy con test.bat
The cursor will reposition itself under the command prompt, this is normal
Type the following 3 commands, each followed by the [Enter] key:
.
Echo Off
Set abcd=4
Echo abcd
Press CTRL-Z simultaneously (it will show up on screen as ^Z)
A confimation message should state: 1 file(s) copied.
Now type Test to run the batch file. If it runs properly, it means you are indeed dealing with line termination issues. Use a different text editor (don't use Notepad!!!), ideally one where you have an option to display the line termination characters (I personnally use NotePad++, it works great for these kinds of things but there are many others out there).
Perhaps there is a problem with your environment variables. Check the following:
Press WIN + R and run "%SYSTEMROOT%\System32\SystemPropertiesAdvanced.exe"
Click on "Environment Variables"
The system variables are listed at the bottom. Select the variable "Path" and click "Edit..."
Check whether the list contains "C:\Windows\System32" or "%SYSTEMROOT%\System32". If not, add one of those. You may have to restart your computer afterwards.
I'm trying to add a right click option to every file so that it executes a command. Seemed simple enough at first glance.
Right click option
By going in the registry editor, specifically HKCR\*\shell (which represents the context menu options that appear for every file type, hence the "*"), I added my own key as such :
HKEY_CLASSES_ROOT
*
shell
my_right_click_option
(Default) = "Click me!"
command
(Default) = my_command
Command
After this, the clickable entry appeared in the context menu instantly.
In my case, the key is called "checkmd5" and the command key's "Default" value stores the command 'my_command' to execute when clicked.
The command is :
"C:\Quite_a_long_path\md5\md5.exe" -n "%1" | clip
The -n option (an md5.exe switch) is just to remove the name of the program that gets displayed after the hash.
The %1 will be replaced by the right clicked program's path, and the double quotes are used in case any of the paths contain some whitespaces.
Sadly, all I've managed to do is execute the command (a cmd window appears and disappears, which means that the cmd has been executed) and also, just to be sure, I checked with Process Monitor (from the SysInternals Suite) the command line being executed in the small cmd window that appears and disappears and it looks like the command I put is being executed exactly as I wanted.
Nonetheless, even after appending to the command either "| clip" (to redirect output to clipboard) or "> file.txt" (to a file) [I tried using an absolute path for file too], the clipboard doesn't update, nor the file.txt gets created with the output of the command..
I can't seem to understand how to make it work..
Any help from you windows savvy will be greatly appreciated.
Thank you again for your patience, especially after getting to the end of this long post.
Turns out the only way to use the re-directions is by adding the cmd.exe /C before the command to be executed so that the command interpreter (cmd.exe) understands the redirection and not the program to be executed (aprogram.exe).
e.g:
aprogram.exe -param0 string > C:\temp\file.txt
wouldn't work, because aprogram.exe doesn't know how to manipulate redirections.
Instead it should be :
cmd.exe /C aprogram.exe -param0 string > C:\temp\file.txt
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.
I am trying to print a pdf file from dos, in windows xp.
C:\>print c:\dos.pdf /D:"\\jayaprada-pc\HP LaserJet 1018"
C:\dos.pdf is currently being printed
Its saying doc is being is printed. but no print is coming my printer.
Its showing the document in printer spooler window.
When giving print normally from adobe reader , print is coming fine.
What is wrong with my config.
Actually i want to print a pdf document from command line , so it wont pop up printer properties.
Suggest me any other alternative or third party tool that can be used print from command line in windows.
Use this:
AcroRd32.exe /t <file.pdf> <printer_name> <printer_driver> <printer_port>
For example:
"C:\Program Files (x86)\Adobe\Reader 11.0\Reader\AcroRd32.exe" /t "D:\File.pdf" "Brother MFC-7820N USB Printer" "Brother MFC-7820N USB Printer" "IP_192.168.10.110"
Note: To find the printer information, right click your printer and choose properties.
In my case shown above, the printer name and driver.