0

I started my solution with what was suggested here GhostScript print to network printer in silent mode

And came up with this as a command line

gswin32c.exe -dPrinted -dBATCH -dNOPAUSE -dNOSAFER -q -dNumCopies=1 -sDEVICE=mswinpr2 -sOutputFile="%printer%\\printserver\testprinter" "C:\absolute\file\path.pdf"

And it works nicely, when the printer is available. When the printer is not available (or doesn't exist), it spawns a print dialog. This command is being run by a custom cron service and therefore gets stuck when the dialog opens on a non interactive user.

Is there a command line switch to tell it to send to STDERR instead and just fail the print job?

Alternatively, is there a way to get ghostscript to output the available devices and I could search for the device before printing?

Trevor
  • 101

1 Answers1

0

I was able to find a solution.

Using the command wmic printer get Name I get a list of printer names. Then if the required printer is in the list, I allow the ghostscript command to run, if not then I block it. This helps lower the chance of a lockup from the printer selection dialog popping up on an non interactive user.

Trevor
  • 101