网络打印机安装脚本(rundll32 printui.dll,PrintUIEntry用法示例)

来源:互联网 发布:网络流程图 编辑:程序博客网 时间:2024/05/17 22:41

先将以下代码保存成为Add_Printer_Port.reg文件,用于创建网络打印机使用的标准TCP/IP端口:

 

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE
SYSTEMCurrentControlSetControlPrintMonitorsStandard TCP/IP PortPorts]
"StatusUpdateInterval"=dword:0000000a
"StatusUpdateEnabled"=dword:00000001

[HKEY_LOCAL_MACHINE
SYSTEMCurrentControlSetControlPrintMonitorsStandard TCP/IP PortPortsIP_10.xx.xx.xx]
"Protocol"=dword:00000001
"Version"=dword:00000001
"HostName"=""
"IPAddress"="10.xx.xx.xx"
"HWAddress"=""
"PortNumber"=dword:0000238c
"SNMP Community"="public"
"SNMP Enabled"=dword:00000001
"SNMP Index"=dword:00000001

 

然后使用rundll32 printui.dll,PrintUIEntry的方法可以为客户端安装网络打印机,驱动程序位于客户端可以访问的网络路径上,参考以下示例:

 

REM #*************************************************************************************
REM
 #
REM
 # Modified by Acer for YK Printer hp LaserJet 1300 PS in Dec 06 2005
REM
 # 使用此脚本需要本地安装驱动的权限
REM
 #
REM
 #*************************************************************************************

@echo off

cls
echo Please log on as administrator to run this script.
echo Press any key or use Ctrl+C to terminate the script and log on as administrator.
pause

echo.
echo Import Standard TCP/IP Port register info
regedit 
/s Add_Printer_Port.reg

echo.
echo After making changes to the registry, the Spooler service must be restarted for the new ports to be available.
net stop spooler & net start spooler

REM #*************************************************************************************
REM
 #
REM
 # /ia 用 inf 文件安装打印机驱动程序
REM
 # /if 用 inf 文件安装打印机
REM
 # /b[name] 基本打印机名
REM
 # /c[name] 如果操作在远程机器上,unc 机器名
REM
 # /dl 删除本地打印机
REM
 # /dn 删除网络打印机连接
REM
 # /dd 删除打印机驱动程序
REM
 # /f[file] inf 文件或输出文件
REM
 # /h[arch] 驱动程序体系结构,为下列之一: Alpha | Intel | IA64
REM
 # /m[model] 打印机驱动程序型号名
REM
 # /n[name] 打印机名
REM
 # /v[version] 驱动程序版本属于下列中的一个: Windows 95、98 和 ME | Windows NT 4.0 | Windows NT 4.0 或 2000 | Windows 2000 或 XP|  Windows XP 
REM
 # /q 安静模式,不显示错误信息
REM
 # /r[port] 端口名
REM
 # /y 将打印机设为默认打印机
REM
 # /z 不要自动共享这台打印机
REM
 # /Z 共享这台打印机,只能跟 /if 选项一起使用
REM
 #
REM
 #
REM
 # 更多的帮助请使用rundll32 printui.dll,PrintUIEntry /?
REM
 #
REM
 #*************************************************************************************

echo Remove existing Printer with the same Name to avoid getting copy after copy
rundll32 printui
.dll,PrintUIEntry /dl /"hp LaserJet 1300 PS" /q

echo .
echo Installing hp LaserJet 1300 PS Printer......
rundll32 printui
.dll,PrintUIEntry /if /"hp LaserJet 1300 PS" /"/MyServerPrint Drivershp1300Nlj1300pswin2kxp-schp1300mp.inf" /"IP_10.xx.xx.xx" /"hp LaserJet 1300 PS" /z


Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=1135888


原创粉丝点击