中国DOS联盟论坛

中国DOS联盟

-- 联合DOS 推动DOS 发展DOS --

联盟域名:www.cn-dos.net  论坛域名:www.cn-dos.net/forum
DOS,代表着自由开放与发展,我们努力起来,学习FreeDOS和Linux的自由开放与GNU精神,共同创造和发展美好的自由与GNU GPL世界吧!

游客:  注册 | 登录 | 命令行 | 会员 | 搜索 | 上传 | 帮助 »
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » 怎样用命令行方式添加打印机端口? (已解决)
作者:
标题: 怎样用命令行方式添加打印机端口? (已解决) 上一主题 | 下一主题
rubik
初级用户





积分 102
发帖 35
注册 2006-3-16
状态 离线
『楼 主』:  怎样用命令行方式添加打印机端口? (已解决)

用命令行方式添加打印机是比较简单的,现在我的问题是这样的, 有一台网络打印机,用下面附录的方式安装驱动程序是没有问题的, 一个DOS命令就可以搞定,但是需要创建一个TCP/IP 的端口,即不是 用的LPT1或LPT2等等而是用的一个IP地址的端口。这个创建端口的步骤 不知是否能用哪一个命令来以命令行的方式实现? 盼解 。 …… 附添加打印机的方法 -------------------------------------------------------------------------------------------------------------------------- support.microsoft.com ... 在 Windows 中如何在无用户交互的情况下添加打印机 察看本文应用于的产品 文章编号 : 189105 最后修改 : 2006年1月23日 修订 : 5.1 概要 Windows 2000 和 Windows Server 2003 提供使用命令行安装打印机的功能。当您使用登录脚本或预定事件从一组用户添加或删除打印机时,此功能尤其有用。 虽然 Microsoft Windows NT 4.0 Zero Administration Kit (ZAK) 包含一些诸如 Con2prt.exe 的工具,但是通过 Con2prt.exe 工具,只能添加或删除网络打印机。您还可以使用 Windows 2000 修改和删除本地打印机。因此,管理员可以通过使用户运行批处理文件或登录脚本,从而控制用户打印能力的所有方面。 注意:如果在登录脚本或客户端启动的批处理文件中使用此命令,则客户端计算机需要运行 Windows 2000 或 Windows Server 2003。由于要在客户端计算机上运行登录脚本,因此 Windows NT 4.0 客户端无法处理此命令。 此外,可以从管理员的工作站或者从服务器运行这些命令,从而向客户端计算机推送安装打印机,而无须从实际的计算机执行安装。 更多信息 下面的示例列出此命令的最常见用法。 注意:此命令只能在基于 Windows 2000 或基于 Windows Server 2003 的计算机上运行,该计算机对应的服务器或工作站可以为 Windows 2000、Windows Server 2003 或 Windows NT 4.0。 下面的示例在一台名为 SERVER 的计算机上添加一个 Agfa 打印机驱动程序,并创建一个逻辑打印机。 注意:这两行都可以放入批处理文件中,也可以在命令提示符下按照任意顺序键入。这两行已换行以便于阅读。 rundll32 printui.dll,PrintUIEntry /ia /c\\server /m "AGFA-AccuSet v52.3" /h "Intel" /v "Windows 2000" /f %windir%\inf\ntprint.inf rundll32 printui.dll,PrintUIEntry /if /b "Test Printer" /c\\SERVER /f "%windir%\inf\ntprint.inf" /r "lpt1:"/m "AGFA-AccuSet v52.3" 下面的示例从名为 SERVER 的计算机中删除 Agfa 打印机: rundll32 printui.dll,PrintUIEntry /dl /n "Test Printer" /c\\SERVER 有关可用开关的更多信息,请在该命令后键入 /?。 此外,在命令提示符处,键入: rundll32 printui.dll,PrintUIEntry /? 上面的命令可显示用法开关的完整列表,并提供使用此方法的详细示例。 此外,在命令提示符处,键入: rundll32 printui.dll,PrintUIEntry /Xs /n "printer" ? 上面的命令可显示有关更改打印机属性的其他帮助信息。下面的示例将当前的打印机驱动程序切换至指定的新打印机驱动程序(已安装在服务器上): rundll32 printui.dll,PrintUIEntry /Xs /n\\SERVER\PRINTERSHARENAME DriverName "Lexmark C752 PS3" 注意:下面是一个语法示例,只要创建“标准 TCP/IP 端口”,该语法即可正确运行。 rundll32 printui.dll,PrintUIEntry /if /b "NORTH-US-SRTEST-TEST24-BOGUS" /f %windir%\inf\ntprint.inf /r "IP_157.57.50.98" /m "HP Laserjet 4000 Series PCL" /Z 如果没有创建“标准 TCP/IP 端口”,则可能出现下面的错误对话框: 打印机用户界面 打印机 rundll 命令失败。 命令:/if /b "NORTH-US-SRTEST-TEST24-BOGUS" /f %windir%\inf\ntprint.inf /r "IP_157.57.50.98" /m "HP Laserjet 4000 Series PCL" /Z。 您输入了错误的打印机名称,或者指定的打印机已不再与服务器保持连接。有关更多信息,请单击帮助。 -------------------------------------------------------------------------------- 这篇文章中的信息适用于: ? Microsoft Windows 2000 Server ? Microsoft Windows 2000 Professional Edition ? Microsoft Windows Server 2003 Standard Edition ? Microsoft Windows Server 2003 Datacenter Edition ? Microsoft Windows Server 2003 Enterprise Edition ? Microsoft Windows Server 2003 Web Edition 回到顶端 关键字: kbhowto kbprint KB189105 用rundll32.exe 吧! 我用过的,直接放在unattention.sif [runonce]中加入这方面的脚本。 具体使用方法请见: 用法: rundll32 printui.dll,PrintUIEntry [options] [@commandfile] /a[file] 二进制文件名 /b[name] 基本打印机名 /c[name] 如果操作在远程机器上,unc 机器名 /dl 删除本地打印机 /dn 删除网络打印机连接 /dd 删除打印机驱动程序 /e 显示打印首选项 /f[file] inf 文件或输出文件 /ga 添加每个机器打印机连接 /ge 枚举每个机器打印机连接 /gd 删除每个机器打印机连接 /h[arch] 驱动程序体系结构,为下列之一: Alpha | Intel | IA64 /ia 用 inf 文件安装打印机驱动程序 /id 用添加打印机驱动程序向导安装打印机驱动程序 /if 用 inf 文件安装打印机 /ii 用带 inf 文件的添加打印机向导安装打印机 /il 用添加打印机向导安装打印机 /in 添加网络打印机连接 /j[provider] 打印提供程序名称 /k 将测试页打印到指定的打印机,不能安装打印机时的命令组合 /l[path] 打印机驱动程序源路径 /m[model] 打印机驱动程序型号名 /n[name] 打印机名 /o 显示打印机队列查看 /p 显示打印机属性 /q 安静模式,不显示错误信息 /r[port] 端口名 /s 显示服务器属性 /Ss 将打印机设置存到一个文件 /Sr 从一个文件还原打印机设置 储存或还原必须放在命令结尾的打印机设置选项标志: 2 PRINTER_INFO_2 7 PRINTER_INFO_7 c 颜色配置文件 d 打印机数据 s 安全描述符 g 全局 DevMode m 最低设置 u 用户 DevMode r 解决名称冲突 f 强制使用名称 p 解析端口 /u 如果已安装,则使用现有的打印机驱动程序 /t[#] 起始的以零为基础的索引页 /v[version] 驱动程序版本属于下列中的一个: Windows 95、98 和 ME | Windows NT 4.0 | Windows NT 4.0 或 2000 | Windows 2000 或 XP| Windows XP /w 如果指定的驱动程序不在 inf 中,则提示用户 /y 将打印机设为默认打印机 /Xg 获得打印机设置 /Xs 设定打印机设置 /z 不要自动共享这台打印机 /Z 不要自动生成打印机名 /K 更改 /v 和 /h 的意义来将 Windows IA64 | Windows NT x86 | Windows NT Alpha_AXP | Windows 4.0 分别接受为 0、1、2、3 /Z 共享这台打印机,只能跟 /if 选项一起使用 /? 帮助信息 @[file] 命令行参数文件 /Mw[message] 确认命令之前显示警告消息 /Mq[message] 确认命令之前显示确认消息 /W[flags] 指定向导(APW 和 APDW)的标志和切换 r 使向导可以从上一页重新启动 /G[flags] 指定全局标志和切换 w 抑制安装程序驱动程序警告 UI (超级静声模式) 例如: 运行服务器属性: rundll32 printui .dll ,PrintUIEntry /s /t1 /n\\machine 运行打印机属性: rundll32 printui .dll ,PrintUIEntry /p /n\\machine\printer 在本地运行添加打印机向导: rundll32 printui .dll ,PrintUIEntry /il 在 \\machine: rundll32 printui .dll ,PrintUIEntry /il /c\\Machine 运行添加打印机向导 运行队列查看: rundll32 printui .dll ,PrintUIEntry /o /n\\machine\printer 运行 inf 安装: rundll32 printui.dll,PrintUIEntry /if /b "Test Printer" /f %windir%\inf\ntprint.inf /r "lpt1:" /m "AGFA-AccuSet v52.3" 使用 inf 运行添加打印机向导: rundll32printui.dll,PrintUIEntry/ii/%windir%\inf\ntprint.in 添加每个机器打印机连接: rundll32 printui.dll,PrintUIEntry /ga /c\\machine /n\\machine\printer /j"LanMan Print Services" 删除每个机器打印机连接: rundll32 printui.dll,PrintUIEntry /gd /c\\machine /n\\machine\printer 枚举每个机器打印机连接: rundll32 printui.dll,PrintUIEntry /ge /c\\machine 用 inf 添加打印机驱动程序: rundll32 printui.dll,PrintUIEntry /ia /c\\machine /m "AGFA-AccuSet v52.3" /h "Intel" /v "Windows 2000 或 XP" /f %windir%\inf\ntprint.inf 用 inf 添加打印机驱动程序: rundll32 printui.dll,PrintUIEntry /ia /K /c\\machine /m "AGFA-AccuSet v52.3" /h "Windows NT x86" /v 3 删除打印机驱动程序: rundll32 printui.dll,PrintUIEntry /dd /c\\machine /m "AGFA-AccuSet v52.3" /h "Intel" /v "Windows 2000 或 XP" 删除打印机驱动程序: rundll32 printui.dll,PrintUIEntry /dd /K /c\\machine /m "AGFA-AccuSet v52.3" /h "Windows NT x86" /v 3 将打印机设为默认打印机: rundll32 printui.dll,PrintUIEntry /y /n "printer" 设置打印机注解: rundll32 printui.dll,PrintUIEntry /Xs /n "printer" comment "My Cool Printer" 取得打印机设置: rundll32 printui.dll,PrintUIEntry /Xg /n "printer" 取得文件中的打印机设置保存结果: rundll32 printui.dll,PrintUIEntry /f "results.txt" /Xg /n "printer" 设置打印机设置命令使用: rundll32printui.dll,PrintUIEntry/Xs/n"printer"? 将所有打印机设置存入一个文件: rundll32 printui.dll,PrintUIEntry /Ss /n "printer" /a "file.dat" 从一个文件还原所有打印机设置: rundll32 printui.dll,PrintUIEntry /Sr /n "printer" /a "file.dat" 将二级打印机信息存入一个文件: rundll32 printui.dll,PrintUIEntry /Ss /n "printer" /a "file.dat" 2 从一个文件还原打印机安全描述符: rundll32 printui.dll,PrintUIEntry /Sr /n "printer" /a "file.dat" s 从一个文件还原打印机全局 devmode 和打印机数据: rundll32 printui.dll,PrintUIEntry /Sr /n "printer" /a "file.dat" g d 从文件最少设置还原并分析端口名: rundll32 printui.dll,PrintUIEntry /Sr /n "printer" /a "file.dat" m p [ Last edited by rubik on 2007-1-6 at 12:49 AM ]


   此帖被 +26 点积分       点击查看详情   
评分人:【 lxmxn 分数: +4  时间:2007-1-5 23:56
评分人:【 huahua0919 分数: +7  时间:2008-10-7 20:44
评分人:【 everest79 分数: +15  时间:2008-10-7 20:46


2007-1-5 07:31
查看资料  发送邮件  发短消息 网志   编辑帖子
rubik
初级用户





积分 102
发帖 35
注册 2006-3-16
状态 离线
『第 2 楼』:  没人理睬?

今天又搜索了一天,找到点好东西,先放在这儿分享一下,马上试 ----------------- This tip was submitted to the SearchWin2000.com tip exchange by member David Savoie. Please let other users know how useful it is by rating it below. -------------------------------------------------------------------------------- This tip explains how to create printer ports and shared printers programmatically in a clustered environment. Assumptions: Kerberos support for the cluster has been enabled for each clustered resource as per: PSS ID Number: 235529 Access to Resource Kit Utility REGINI There are two steps to this process: Define printer ports on each node of the cluster. Create shared printers on each node of the cluster. Define printer ports: NOTE: Printer ports should be defined on each node of the cluster. If you have a range of printers, you may want to manually split the range between the two virtual nodes. Step1: Use IP.bat to Create portmaker batch file. Rename IP.txt to Portmaker.bat. This file will be used to create ports on PRINT_NODE1 node of the cluster. Perform the same process for PRINT_NODE2. Modify IP.bat to reflect the new range of printer ports and PRINT_NODE: FOR /L %%I IN (128,1,254) DO CALL :TEST %%I Listing for IP.bat FOR /L %%I IN (0,1,127) DO CALL :TEST %%I :TEST ECHO CALL PORT.BAT 192.168.0.%1 >>IP.TXT ECHO CALL PORTCREATE.BAT PRINT_NODE1>>IP.TXT. PORTMAKER.BAT Sample output CALL PORT.BAT 192.168.0.0 CALL PORTCREATE.BAT PRINT_NODE1 CALL PORT.BAT 192.168.0.1 CALL PORTCREATE.BAT PRINT_NODE1 Port.bat creates the port.ini file that Portcreate.bat uses to apply the registry changes using the Regini Resource Kit utility. Note the GUID. Each virtual server stores its resources under a different GUID. You will need to verify this manually using REGEDT32. Listing for Port.bat echo >port.ini RegistryMachineClusterResources222eca55-e86a-4b3f-9091- c47d6f7ac5e6ParametersMonitorsStandard TCP/IP PortPortsIP_%1 echo >>port.ini HostName = REG_SZ echo >>port.ini HWAddress = REG_SZ echo >>port.ini IPAddress = %1 echo >>port.ini PortNumber = REG_DWORD 9100 echo >>port.ini Protocol = REG_DWORD 1 echo >>port.ini SNMP Community = REG_SZ "public" echo >>port.ini SNMP Enabled = REG_DWORD 1 echo >>port.ini SNMP Index = REG_DWORD 1 echo >>port.ini Version = REG_DWORD 1 Listing for Portcreate.bat regini -m \%1 port.ini Creating print shares: Use the following two batch files to mass-create shared printers. Sample listing of PRINTCREATE.BAT: CALL DRIVER.BAT 8N7 PRINT_NODE1 192.168.0.1 Xerox Docuprint N32 Listing of Driver.bat rundll32 printui.dll,PrintUIEntry /if /b "%1" /c \%2 /f %windir% infntprint.inf /r "IP_%3" /m "Xerox Docuprint N32" /h "Intel" /v "Windows NT 4.0 or 2000" /u /Z rundll32 printui.dll,PrintUIEntry /Xs /c \%2 /n "\%2%1" comment "%4 %5 %6" rundll32 printui.dll,PrintUIEntry /Xs /c \%2 /n "\%2%1" location "%1" NOTE: If the driver does not exist on the second node, you can run the following command on the second node to install the driver: rundll32 printui.dll , PrintUIEntry /id You may need to stop and start the cluster service on each node to refresh the print queue information held in Active Directory.


2007-1-5 23:47
查看资料  发送邮件  发短消息 网志   编辑帖子
vkill
金牌会员





积分 4103
发帖 1744
注册 2006-1-20
来自 甘肃.临泽
状态 离线
『第 3 楼』:  

这个好好看看,觉得不错


2007-1-6 01:48
查看资料  发送邮件  访问主页  发短消息 网志   编辑帖子
huahua0919
银牌会员




积分 1608
发帖 780
注册 2007-10-7
状态 离线
『第 4 楼』:  

我要把他学会,谢谢楼主


2008-10-7 20:44
查看资料  发送邮件  访问主页  发短消息 网志   编辑帖子
exzzz
初级用户

游手好闲 + 无所事事 ..



积分 194
发帖 167
注册 2007-4-30
状态 离线
『第 5 楼』:  

你说的这种情况我经常遇到,因为回答比较麻烦,所以我新建了一个帖子,供其它人使用,请参考这里: www.cn-dos.net/forum ...


2008-12-15 15:04
查看资料  发送邮件  发短消息 网志   编辑帖子

请注意:您目前尚未注册或登录,请您注册登录以使用论坛的各项功能,例如发表和回复帖子等。


可打印版本 | 推荐给朋友 | 订阅主题 | 收藏主题



论坛跳转: