中国DOS联盟论坛

China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
Guest | Log in | Register | Members | Search | China DOS Union
中国DOS联盟论坛
The time now is 2026-09-30 05:43
47,813 topics / 349,918 posts / today 0 new / 48,278 members
DOS批处理 & 脚本技术(批处理室) » Batch processing to batch add printers (including print servers)
Printable Version  3,444 / 7
Floor1 exzzz Posted 2008-12-15 14:37
初级用户 Posts 167 Credits 194
Purpose:
Batch - add printers according to the printer configuration file. For example, a computer needs to install a local parallel port printer and a network print server at the same time (not sharing the printer of other computers, but the printer that can be connected to the switch with a network cable).

Implementation steps:
1. Poll the "Printer X.txt" in the directory. According to the port description in it, judge whether it is a local LPT port. If it is a local LPT printer, ignore it. If it is a print server, automatically create a new TCP/IP port.
2. Restart the print service to make the newly created local IP port take effect.
3. Poll the "Printer X.txt" in the directory. According to the printer name, driver location, printer model and printer port, add the print server.

Key statement:
rundll32 printui.dll,PrintUIEntry /?

Defect:
Because I don't need local printers with USB ports and don't use shared printers, there are no statements added to judge such printers.

★★★★★★★★★
The following is the batch code



★★★★★★★★★
The content of the network print server configuration file "Printer 1.txt":


★★★★★★★★★
The content of the local printer configuration file "Printer 2.txt":


[ Last edited by exzzz on 2008-12-15 at 14:46 ]

Attachments
添加网络打印机0302.zip (2.09 KiB)
Floor2 HAT Posted 2008-12-15 14:41
版主 Posts 5,017 Credits 9,023
It is suggested to change the first line to @echo off, and delete all other @
Floor3 exzzz Posted 2008-12-15 14:45
初级用户 Posts 167 Credits 194
Thanks, moderator, for your concern!

I took a little shortcut, heh heh. The part with @..... was copied from my other batch script, and I was too lazy to replace it. After echo off, I'm used to cls, a bad habit I formed years ago that I still can't get rid of...
Floor4 iyuohz Posted 2009-03-18 06:59
新手上路 Posts 3 Credits 4
What about adding a USB - connected printer? How should it be written?
Floor5 exzzz Posted 2009-03-19 01:40
初级用户 Posts 167 Credits 194
I haven't installed USB before, but you can first install it manually once. Check what characters are there in the port properties of the printer. I remember it should be something like USB01: or the like. You can modify the printer IP in the txt file and that should work.

And according to the characteristics of USB devices, you should be able to install it on any port randomly, such as network or LPT, then uninstall it after installation. Then when you restart, it will be automatically installed in the background.
Floor6 iyuohz Posted 2009-03-19 09:59
新手上路 Posts 3 Credits 4
Originally posted by exzzz at 2009-3-19 01:40:
I haven't installed USB ones, but you can first install manually once, check what characters are in the printer port properties, remember it should be something like USB01: and so on, modify the printer IP in the txt file...


USB001

But it doesn't work.

I tried it

When installing to the end, it appears that the printer cannot be installed

I don't know the reason

It seems that "virtual printer" is also a new port ah,

Why does USB have to be connected to the printer to work?
Floor7 zuimeng Posted 2010-06-27 11:37
初级用户 Posts 83 Credits 170
Because the USB ports are generated randomly, and a USB port is created only when a USB printer is connected.

In Windows 2000 and XP systems, USB interface devices are all regarded as plug-and-play devices, so USB printers will not have a specifically pre-designated port in the list.
Only after connecting the printer will it be randomly assigned according to system interrupts, ports and other issues. So if your printer is a USB port, after you plug in the printer and turn on the printer power, the system will automatically search and install.
Floor8 zjf3342 Posted 2010-07-26 17:46
新手上路 Posts 1 Credits 1
This simply cannot achieve the functions you mentioned. Ports cannot be added, let alone installing a printer.
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023