Windows – Print from command line

If you need to print from windows command line, you have three options depending on What Kind of file you need to print.

TEXT PRINTING

  • Assign a COM port to your printer.
    1. Open Start → Control Panel → Devices and Printers.
    2. Right-click your printer and select Properties.
    3. In the Ports tab, assign an unused port from COM1: to COM4: to your printer.
    If you chose, e.g., COM3, print using the following command:

    print /d:COM3 test.txt
  • Share the printer.
    1. Open Start → Control Panel → Devices and Printers.
    2. Right-click your printer and select Properties.
    3. In the Sharing tab, decide to share the printer and assign a share name to it.
    If you chose, e.g., myPrinter, print using the following command:

    print /d:\\%COMPUTERNAME%\myPrinter test.txt

 

  • PICTURE PRINTING
    Print behind a native software made for that.
     

    mspaint /pt filename

 
That’s all, I hope this code has been helpful.

Windows – Print from command line