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?