For your better understanding let’s check out the basic DOS printing commands before going to the advanced methods. If you are using a dot matrix printer which is installed on your local system then the below code can be used for the printing. Here we are assuming that “printfile.txt” is the file, which we want to send to the local printer for printing.
type printfile.txt > LPT1:
If your printer is installed on a different computer in your LAN and its being shared to your local computer then you have to use the below printing command. Here we are assuming that “Computer2” is the computer name where your printer is installed and “NetworkPrinter” is the sharing name of that printer.
copy printfile.txt \\Computer2\NetworkPrinter
Even though we say DOS printing is really economical and user friendly, the quality of the output we cannot match with the Laser Printers or Inkjet printers. This fact forces most of the people to go for a Laser Printer or Inkjet Printer. This situation put the developers in trouble, because most of the latest Laser Printers and Inkjet printers, connecting using USB ports, and the above codes will not work with USB ports. So we need to have a different code or even different printer port to print to USB ports. Here we need to make certain changes to the printer settings before printing. You need to share your local printer, for example we will give the sharing name as “LocalPrinter” and the computer name as “Computer1”
Net Use LPT2: \\Computer1\LocalPrinter /PERSISTENT:YES
I used to do these coding in VB.Net, but it will work in almost all programming languages.
Hopping this may be helpful to some one…