如何使用 BATCH 脚本在 Windows 上通过 IP 添加打印机

qro*_*rts 3 windows printer batch ip

我希望能够创建一个 BATCH 脚本,该脚本将使用 TCP/IP 端口在本地添加打印机。我假设所需的参数是打印机名称、驱动程序位置 (.inf)、IP 地址和计算机名称。

任何人都可以提供帮助?

Fop*_*ush 5

您可以通过几次调用 printui 来完成此操作 -有关更多信息,请参阅此页面。听起来你想打电话

rundll32 printui.dll,PrintUIEntry /ga
Run Code Online (Sandbox Code Playgroud)

虽然我不确定如何通过网络上的 INF 文件指定打印机。

几年前,我写了一个脚本来通过网络安装打印机。此脚本旨在与通过 samba 共享的打印机一起使用,因此您无需指定驱动程序。如果您尝试添加未以这种方式共享的打印机,我不确定这是否可行。也许您可以以此为起点来弄清楚如何去做。

@echo off
::
::This script adds a single printer to the default user profile.
::NOTE:  Printer names with spaces will NOT be accepted.  
::Usage: run addprinters and follow onscreen directions


cls
echo This script adds the specified local or network printer  
echo to the deafult account for all existing/new users.  
echo *IMPORTATNT* Printer names with spaces will NOT be accepted.
echo *******************************************************

SET /P target=Enter target computer name (this compupter)  
SET /P printer=Enter Printserver/Printername (do not include \\) 
echo Attempting to add %printer% for all users on %target%


rundll32 printui.dll,PrintUIEntry /ga /c\\%target% /n\\%printer%
echo New printers will NOT appear until spooler is restarted.
SET /P reset=Reset print spooler Y/N?     
if "%reset%"=="y" goto spooly
goto end

:spooly
start /wait sc \\%target% stop spooler
start /wait sc \\%target% start spooler
echo Print Spooler Service restarted.

:end
Run Code Online (Sandbox Code Playgroud)

如果您想尝试一下,只需将此文本保存到 .cmd 文件并运行它。