views:

33

answers:

0

A few years back, another clever programmer set up a VB.NET service to print to one of the server's installed printers. The job queried a database table to see if it had any print requests, which specify the file to print and the name of the printer to send it to. The job constructs a 3-part command line incantation and executes it; it goes a little something like this:

net use LPT2: IP_1.2.3.4 /user:domain\userid password >> netuse1.out
copy someExistingFile.pdf LPT2 >> copy.out
net use LPT2: /delete >> netuse2.out

We've been asked to make other unrelated changes to this job, and happily complied. Only any version of the job we deploy and run simply will not print. The first statement fails with "System error 67 has occurred. The network name cannot be found."

The job has queried the registry to find the port name for the printer specified by the user. The port it tries is indeed the port "name" we see when looking at the printer's properties. So that's, uh, correct.

Except...wait a minute, what in the heck is a "port name"? It's not a valid IP address (though it IS the IP address of the printer itself, prefixed with "IP_". Nothing I can find on NET USE ever says anything about a printer port, only a computer/share [and optional volume].

Can anyone shed any light as to whether this could have EVER worked?

[Of course, no one can provide us with the source for the version of the service that actually still works. We've not touched this portion of the service, only what precedes this printing. And the client swears they haven't either. Grrr...]

We are looking at a more modern way of printing, though the fact that it needs to run as a service complicates things.