批处理如何安装网络打印机

发布时间:2021-10-29 10:40:18 作者:小新
来源:亿速云 阅读:199

这篇文章主要为大家展示了“批处理如何安装网络打印机”,内容简而易懂,条理清晰,希望能够帮助大家解决疑惑,下面让小编带领大家一起研究并学习一下“批处理如何安装网络打印机”这篇文章吧。

*Because there are many Windows computers in the company, using traditional manual steps to install printer drivers step by step is really too cumbersome and wasting time. Now we want to implement script installation of network printers.

@echo on
echo     Auto to inistall print driver!!!

color 0a

rem 以下是判断端口
set count=0
:addreginfo
set /a count=%count%+1
if exist 打印机%count%.txt (set filename=打印机%count%.txt) else (goto eof)
for /f "tokens=2 delims==" %%a in ('type %filename% ^|findstr /I "打印机IP="') do set pIP=%%a

if /I "%pIP%"=="LPT1:" goto addreginfo
if /I "%pIP%"=="LPT2:" goto addreginfo

rem 以下是添加端口在注册表中的信息
set regpath2=HKEYLOCALMACHINE\SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\IP
set regpath3=HKEYLOCALMACHINE\SYSTEM\ControlSet001\Control\Print\Monitors\Standard TCP/IP Port\Ports\IP
@echo off
:addreg1
@reg add "%regpath2%%pip%" /v "Protocol" /d "00000001" /f /t REGDWORD >nul 2>nul
@reg add "%regpath2%%pip%" /v "Version" /d "00000001" /f /t REGDWORD >nul 2>nul
@reg add "%regpath2%%pip%" /v "HostName" /d "" /f >nul 2>nul
@reg add "%regpath2%%pip%" /v "IPAddress" /d "%pip%" /f >nul 2>nul
@reg add "%regpath2%%pip%" /v "HWAddress" /d "" /f >nul 2>nul
@reg add "%regpath2%%pip%" /v "PortNumber" /d "9100" /f /t REGDWORD >nul 2>nul
@reg add "%regpath2%%pip%" /v "SNMP Community" /d "public" /f >nul 2>nul
@reg add "%regpath2%%pip%" /v "SNMP Enabled" /d "00000000" /f /t REGDWORD >nul 2>nul
@reg add "%regpath2%%pip%" /v "SNMP Index" /d "00000001" /f /t REGDWORD >nul 2>nul

:addreg2
@reg add "%regpath3%%pip%" /v "Protocol" /d "00000001" /f /t REGDWORD >nul 2>nul
@reg add "%regpath3%%pip%" /v "Version" /d "00000001" /f /t REGDWORD >nul 2>nul
@reg add "%regpath3%%pip%" /v "HostName" /d "" /f >nul 2>nul
@reg add "%regpath3%%pip%" /v "IPAddress" /d "%pip%" /f >nul 2>nul
@reg add "%regpath3%%pip%" /v "HWAddress" /d "" /f >nul 2>nul
@reg add "%regpath3%%pip%" /v "PortNumber" /d "9100" /f /t REGDWORD >nul 2>nul
@reg add "%regpath3%%pip%" /v "SNMP Community" /d "public" /f >nul 2>nul
@reg add "%regpath3%%pip%" /v "SNMP Enabled" /d "00000000" /f /t REGDWORD >nul 2>nul
@reg add "%regpath3%%pip%" /v "SNMP Index" /d "00000001" /f /t REGDWORD >nul 2>nul
goto addreginfo
:eof

rem 以下是重新启动打印服务,使新端口生效
:restartservice
cls
echo.           Don`t close this window, you are adding a printer. Please wait a minute.

echo.
echo 正在启用打印机端口...
echo.
net stop spooler >nul 2>nul
net start spooler >nul 2>nul

rundll32 printui.dll,PrintUIEntry /dl /n "TOSHIBA e-STUDIO455Series PCL6" /f "%pinf%" /r "%pIP%" /q

rem 以下是添加打印机
set count=0
:instprinter
set /a count=%count%+1
if exist 打印机%count%.txt (set filename=打印机%count%.txt) else (goto over)

for /f "tokens=2 delims==" %%a in ('type %filename% ^|findstr "打印机IP="') do set pIP=%%a
for /f "tokens=2 delims==" %%a in ('type %filename% ^|findstr "打印机名称="') do set pname=%%a
for /f "tokens=2 delims==" %%a in ('type %filename% ^|findstr "打印机型号="') do set pmodel=%%a
for /f "tokens=2 delims==" %%a in ('type %filename% ^|findstr "打印机INF位置="') do set pinf=%%a
echo.

echo.
echo.Already added, the printer information is as follows:
echo.
echo  IP  :%pIP%
echo 名称 :%pname%
echo 型号 :%pmodel%
:echo 驱动 :%pinf%
if /I "%pIP%"=="LPT1:" (goto ok)
if /I "%pIP%"=="LPT2:" (goto ok) else (set pip=IP%pip%)
:ok
rundll32 printui.dll,PrintUIEntry /if /b "%pname%" /f "%pinf%" /r "%pIP%" /m "%pmodel%"
goto instprinter
:over
echo.
color 0b
echo  If you have any problems, please contact the administrator.
pause
exit
echo 请按任意键退出
★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★ *


网络打印服务器配置文件“打印机1.txt”的内容:

打印机IP=172.16.9.2
打印机名称=TOSHIBA e-STUDIO
打印机型号=TOSHIBA e-STUDIO455Series PCL6
打印机INF位置=E:\TOSHIBA_64\110104_Loire_CDV210_CN_XP_VISTA_X64_PLC6\Driver\eS4px6.inf

本地打印机配置文件“打印机2.txt”的内容:
打印机IP=LPT1:
打印机名称=本地HP 3050
打印机型号=HP LaserJet 3050 Series PCL 5e
打印机INF位置=D:\sysbak\打印机\hp3055\Drivers\2K_XP_Vista\hppcp501.inf

以上是“批处理如何安装网络打印机”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注亿速云行业资讯频道!

推荐阅读:
  1. 网络安装Fuji Xerox DocuCentre-III 2007打印机
  2. 安装网络打印机小技巧

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

批处理

上一篇:怎么用源码分析Play Framework hotswap

下一篇:Mysql数据分组排名实现的示例分析

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》