老式 Windows 2000 打印,或者端口名称何时是计算机?

发布于 2024-08-14 05:54:45 字数 762 浏览 3 评论 0原文

几年前,另一位聪明的程序员设置了一个 VB.NET 服务来打印到服务器已安装的打印机之一。该作业查询数据库表以查看是否有任何打印请求,该请求指定要打印的文件以及要将其发送到的打印机的名称。该作业构造一个由 3 部分组成的命令行咒语并执行它;事情大概是这样的:

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

我们被要求对这项工作进行其他无关的改变,我们很高兴地答应了。只有我们部署和运行的作业的任何版本都不会打印。第一条语句失败,并显示“发生系统错误 67。找不到网络名称。”

该作业已查询注册表以查找用户指定的打印机的端口名称。它尝试的端口确实是我们在查看打印机属性时看到的端口“名称”。所以这是,呃,正确的。

除了...等一下,“端口名称”到底是什么?它不是一个有效的 IP 地址(尽管它是打印机本身的 IP 地址,前缀为“IP_”)。我在 NET USE 上找不到任何有关打印机端口的信息,只有计算机/共享[和可选卷]。

任何人都可以阐明这是否曾经有效吗?

[当然,没有人可以向我们提供实际上仍然有效的服务版本的源代码,我们只触及了服务的这一部分。客户发誓他们也没有。 Grrr...]

我们正在寻找一种更现代的打印方式,尽管它需要作为服务运行这一事实使事情变得复杂。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

音盲 2024-08-21 05:54:45

“IP_1.2.3.4”参数是打印机共享名称,而不是端口名称。您必须在过去的某个时刻共享一台已安装的现有打印机,并将其命名为“IP_1.2.3.4”,但此共享名称丢失。

如果您只需要一台直通打印机,您可以安装“通用/纯文本”打印机,将其分配到所需的端口,并使用“net use”命令中的名称共享它。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文