在 Windows 7 上使用 PrintUI 更改打印机驱动程序
我在整栋大楼内安装了大约 200 台相同品牌/型号的本地打印机。问题是默认安装在客户端上放置了两个驱动程序,但将错误的驱动程序设置为默认驱动程序。要手动更改它,我右键单击打印机,选择“打印机属性”,单击“高级”选项卡并更改驱动程序选择,然后单击“确定”。
我需要在所有其他机器上执行此操作,但希望不必手动访问每台机器。我查看了一堆 WMI 脚本以及使用 PrintUI.exe (printui.dll) 的示例。我可以使用以下 printui 语法更改驱动程序选择:
printui /Xs /n "hp LaserJet 8888 PCL 5" DriverName "hp LaserJet 8890 PCL 5"
这似乎有效。但是,问题是,一旦我运行此命令,下次我右键单击打印机并选择“打印机属性”时,系统会提示我使用向导重新安装打印机驱动程序。有没有更好的方法或方法来解决这个问题?
I have about 200 identical make/model local printers installed throughout a building. The problem is that the default installation puts two drivers on the client, but sets the wrong driver as default. To change it manually, I right-click on the printer, choose "Printer Properties", click the "Advanced" tab and change the driver selection and click OK.
I need to do this on all the others, but hopefully not by having to manually visit each machine. I've looked at a bunch of WMI scripts, and examples using PrintUI.exe (printui.dll). I can change the driver selection using the following printui syntax:
printui /Xs /n "hp LaserJet 8888 PCL 5" DriverName "hp LaserJet 8890 PCL 5"
And this seems to work. But, the problem is that once I've run this command, the very next time I right-click on the printer and select "Printer Properties" I am prompted to re-install the printer driver using the wizard. Is there a better way or a way around this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
晚了,但也许可以帮助...如果您使用的是 .inf 文件。
>>>>>>要在没有任何向导的情况下执行此操作,必须对驱动程序进行签名。
Windows 7:
安装:
RUNDLL32 PRINTUI.DLL,PrintUIEntry /if /b“打印机名称” /f "driver.inf" /r "com1" /m "驱动程序型号名称" /h "Intel"
RUNDLL32 PRINTUI.DLL,PrintUIEntry /y /n "打印机名称"
卸载:
要卸载打印机,您需要 3 个命令,并严格遵循以下顺序:
RUNDLL32 PRINTUI.DLL,PrintUIEntry /dl /n "打印机名称" /h "Intel"
RUNDLL32 PRINTUI.DLL,PrintUIEntry /dd /m "驱动程序型号名称" /h "Intel"
代码> .此后您将看不到打印机和驱动程序,但如果拔下 USB 设备并再次插入,驱动程序将自动安装。这是因为Windows将驱动安装包添加到C:\Windows\System32\DriverStore\FileRepository
中,我们需要使用第三条命令将其卸载。pnputil.exe -e
显示所有 oem*.inf 和手中的名称使用此pnputil.exe -f -d oem5.inf
(更改 oem5.inf 的名称以对应于您的 inf 文件)我使用此命令以编程方式完成了这些任务,除了搜索解析
C:\Windows\Inf\
下所有.inf文件所需的oem*.inf名称。使用 cli 安装时需要小心的行为...不要对同一台打印机执行两次安装,Windows 会创建一个随机名称,就像您安装打印机 B 一样,Windows 会重命名为打印机 B (copy_A) 或其他名称如果打印机 B 已经存在。如果您需要卸载,则需要先删除两台打印机,然后再执行第二个命令卸载驱动程序。
有时最好全部卸载并重新安装。
另请参阅有关 devcon 的代码: https://code.msdn.microsoft.com/ windowshardware/DevCon-Sample-4e95d71c
以及有关命令的详细信息:
http://www.robvanderwoude.com/2kprintcontrol.php
late, but maybe can help... if you are using .inf file.
>>>> To do this without any wizard, the driver must be signed.
Windows 7:
INSTALLATION:
RUNDLL32 PRINTUI.DLL,PrintUIEntry /if /b "Printer name" /f "driver.inf" /r "com1" /m "driver model name" /h "Intel"
RUNDLL32 PRINTUI.DLL,PrintUIEntry /y /n "Printer name"
UNINSTALL:
To uninstall a printer you need 3 commands and strict follow the sequence:
RUNDLL32 PRINTUI.DLL,PrintUIEntry /dl /n "Printer Name" /h "Intel"
RUNDLL32 PRINTUI.DLL,PrintUIEntry /dd /m "driver model name" /h "Intel"
. After this you cannot see the printer and the driver, but if you unplug the usb devide and plug again the driver will automatically install. this because windows add the driver installation pack toC:\Windows\System32\DriverStore\FileRepository
and we need to uninstall it with the third command.pnputil.exe -e
to show all oem*.inf and with the name in hands use thispnputil.exe -f -d oem5.inf
(change the name of the oem5.inf to correspond to you inf file)I did thoses taks programmatically using this commands, except to search the oem*.inf name that you need to parse all .inf files under
C:\Windows\Inf\
.There is a behavour that you need care when using cli to install... do not execute two installation for the same printer, windows will create a random name like you install printer B and windows will rename to printer B (copy_A) or something else if the printer B already exist. And if you need to uninstall you will need to remove the two printers before going to the second command to uninstall the driver.
Sometimes is better to uninstall all and install again.
Also see the code about devcon: https://code.msdn.microsoft.com/windowshardware/DevCon-Sample-4e95d71c
And details about the commands:
http://www.robvanderwoude.com/2kprintcontrol.php
我在 Windows XP 上尝试了你的命令行,它对我有用,没有弹出任何打印机向导。我使用了 XP 操作系统本身的两个驱动程序。这就是我使用的 -
rundll32 printui.dll PrintUIEntry /Xs /n "HP Color LaserJet 4550 PCL" DriverName "HP C LaserJet 4500-PS"
也许您可能想再次检查一下。也许 Win7 有一些 PrintUI 没有做对的额外东西?
不过,请注意一点。当您以这种方式切换队列上的驱动程序时,您将丢失旧队列的设置。如果可以的话,那么走这条路就好了。
现在,如果您只想更改每个客户端上的默认打印队列,您应该使用此命令行 - 例如将“HP Color LaserJet 4550 PCL”设置为您使用的队列 -
rundll32 printui.dll,PrintUIEntry /y /n "HP Color LaserJet 4550 PCL”
如果有帮助请告诉我
I tried your command line on Windows XP and it worked for me without popping up any Printer Wizard. I used two drivers that were part of the XP OS itself. This is what I used -
rundll32 printui.dll PrintUIEntry /Xs /n "HP Color LaserJet 4550 PCL" DriverName "HP C LaserJet 4500-PS"
Maybe you may want to check it out again. Probably Win7 has some extra stuff which PrintUI is not doing right?
However, one word of caution. When you switch the drivers on the queue in this way, you lose the settings of the old queue. If this is ok, then going this path would be fine.
Now if you only want to change the default print queue on each client you should use this command-line - Say for setting "HP Color LaserJet 4550 PCL" as the queue you use -
rundll32 printui.dll,PrintUIEntry /y /n "HP Color LaserJet 4550 PCL"
Let me know if this helps