开发者

Old-School Windows 2000 Printing, or When is a Port Name a Computer?

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 printin开发者_开发百科g. 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.


The "IP_1.2.3.4" parameter is the printer share name, not a port name. You must have shared one of the existing installed printers giving it the name "IP_1.2.3.4" at some point in the past, and this share name is missing.

If you just need a passthrough printer, you can install the "Generic/Text Only" printer, assign it to the desired port, and share it using the name in your "net use" command.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜