Batch Script Printing - Batch Script

What is Batch Script Printing?

Printing too be controlled from inside Batch Script via the NET PRINT command.

Syntax

  • Where /D:device - Specifies a print device.

Example

The beyond command will print the example.txt file to the parallel port lpt1.

Command Line Printer Control

As of Windows 2000, many, but not all, printer settings can be configured from Windows's command line using PRINTUI.DLL and RUNDLL32.EXE

Syntax

Where some of the options available are the following −

  • /dl − Delete local printer.
  • /dn − Delete network printer connection.
  • /dd − Delete printer driver.
  • /e − Display printing preferences.
  • /f[file] − Either inf file or output file.
  • /F[file] − Location of an INF file that the INF file specified with /f may depend on.
  • /ia − Install printer driver using inf file.
  • /id − Install printer driver using add printer driver wizard.
  • /if − Install printer using inf file.
  • /ii − Install printer using add printer wizard with an inf file.
  • /il − Install printer using add printer wizard.
  • /in − Add network printer connection.
  • /ip − Install printer using network printer installation wizard.
  • /k − Print test page to specified printer, cannot be combined with command when installing a printer.
  • /l[path] − Printer driver source path.
  • /m[model] − Printer driver model name.
  • /n[name] − Printer name.
  • /o − Display printer queue view.
  • /p − Display printer properties.
  • /Ss − Store printer settings into a file.
  • /Sr − Restore printer settings from a file.
  • /y − Set printer as the default.
  • /Xg − Get printer settings.
  • /Xs − Set printer settings.

Testing if a Printer Exists

There can be circumstances where you might be linked to a network printer instead of a local printer. In such circumstances, it is continuously beneficial to check if a printer exists in the first place before printing.

The existence of a printer can be evaluated with the help of the RUNDLL32.EXE PRINTUI.DLL which is used to control most of the printer settings.

Example

The above command will do the resulting −

  • It will first set the printer name and set a file name which will hold the settings of the printer.
  • The RUNDLL32.EXE PRINTUI.DLL commands will be used to check if the printer actually exists by sending the configuration settings of the file to the file Prt.txt

All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

Batch Script Topics