无忧启动论坛

 找回密码
 注册
搜索
系统gho:最纯净好用系统下载站投放广告、加入VIP会员,请联系 微信:wuyouceo
查看: 7435|回复: 11
打印 上一主题 下一主题

取消打印机的启用双向支持这个脚本怎么写?

[复制链接]
跳转到指定楼层
1#
发表于 2011-2-20 18:23:37 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
特别是以HP的激光机为例,默认就启动了,结果无法打印.
如果写个批处理来实现取消这个勾?
2#
发表于 2011-2-20 20:31:40 | 只看该作者
你先监视一下注册表的变化看看
回复

使用道具 举报

3#
 楼主| 发表于 2011-2-20 21:24:44 | 只看该作者

回复 #2 netwinxp 的帖子

改天我整個測試環境試下。
回复

使用道具 举报

4#
 楼主| 发表于 2011-2-20 21:25:17 | 只看该作者
原帖由 <i>netwinxp</i> 于 2011-2-20 20:31 发表 <a href="http://bbs.wuyou.net/redirect.php?goto=findpost&pid=2164160&ptid=187450" target="_blank"><img src="http://bbs.wuyou.net/images/common/back.gif" border="0" onload="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onmouseover="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor='hand'; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onclick="if(!this.resized) {return true;} else {window.open(this.src);}" onmousewheel="return imgzoom(this);" alt="" /></a><br />
你先监视一下注册表的变化看看
<br />
之前,監視註冊表沒有收穫。
回复

使用道具 举报

5#
 楼主| 发表于 2011-2-21 16:05:11 | 只看该作者
原帖由 netwinxp 于 2011-2-20 20:31 发表
你先监视一下注册表的变化看看

按监视的结果重新导入注册表,也没有效果。

  1. Regshot 1.8.2
  2. 要点注释:
  3. 日期时间:2011/2/21 07:54:35  ,  2011/2/21 07:54:45
  4. 计算机名:XP-201102211333 , XP-201102211333
  5. 使用者名:Administrator , Administrator
  6. ----------------------------------
  7. 修改值:6
  8. ----------------------------------
  9. HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Print\Printers\HP LaserJet 1022\ChangeID: 0x00358626
  10. HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Print\Printers\HP LaserJet 1022\ChangeID: 0x003770B0
  11. HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Print\Printers\HP LaserJet 1022\Attributes: 0x00000A00
  12. HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Print\Printers\HP LaserJet 1022\Attributes: 0x00000200
  13. HKLM\SYSTEM\ControlSet001\Control\Print\Printers\HP LaserJet 1022\ChangeID: 0x00358626
  14. HKLM\SYSTEM\ControlSet001\Control\Print\Printers\HP LaserJet 1022\ChangeID: 0x003770B0
  15. HKLM\SYSTEM\ControlSet001\Control\Print\Printers\HP LaserJet 1022\Attributes: 0x00000A00
  16. HKLM\SYSTEM\ControlSet001\Control\Print\Printers\HP LaserJet 1022\Attributes: 0x00000200
  17. HKLM\SYSTEM\CurrentControlSet\Control\Print\Printers\HP LaserJet 1022\ChangeID: 0x00358626
  18. HKLM\SYSTEM\CurrentControlSet\Control\Print\Printers\HP LaserJet 1022\ChangeID: 0x003770B0
  19. HKLM\SYSTEM\CurrentControlSet\Control\Print\Printers\HP LaserJet 1022\Attributes: 0x00000A00
  20. HKLM\SYSTEM\CurrentControlSet\Control\Print\Printers\HP LaserJet 1022\Attributes: 0x00000200
  21. ----------------------------------
  22. 文件修改:1
  23. ----------------------------------
  24. C:\WINDOWS\system32\config\SOFTWARE.LOG
  25. ----------------------------------
  26. 总计:7
  27. ----------------------------------
复制代码
回复

使用道具 举报

6#
发表于 2011-2-25 09:46:34 | 只看该作者
HKLM\SYSTEM\CurrentControlSet\Control\Print\Printers\HP LaserJet 1022\Attributes:

HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Print\Printers\HP LaserJet 1022\Attributes
两个地方是一样的,修改一个就可以了.
按你上面的信息,改成0x200就可以了.

重要的是要重启打印机服务

net stop spooler & net start spooler

广而告之^_^

更多详细的设置方法见这里,我整了一个批处理.
http://chenall.net/post/win_print_set/
回复

使用道具 举报

7#
 楼主| 发表于 2011-2-25 12:41:36 | 只看该作者

回复 #6 chenall 的帖子

原来是少了这个步骤,难怪死活不成功。咿呀
net stop spooler & net start spooler
回复

使用道具 举报

8#
 楼主| 发表于 2011-2-25 14:40:11 | 只看该作者

回复 #6 chenall 的帖子

现在还有问题,就是下面这个代码,会重复添加,能否加入个判断,先确定是否存在,如果不存在,则再安装。

  1. strComputer = "."
  2. Set objWMIService = GetObject("winmgmts:\" & strComputer & "\root\cimv2")

  3. Set colPrinters = objWMIService.ExecQuery ("Select * From Win32_Printer")


  4. Dim WshShell
  5. Set WshShell=WScript.CreateObject("WScript.Shell")

  6. '添加打印机端口信息
  7. WshShell.RegWrite "HKLM\SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\LprAckTimeout",180,"REG_DWORD"
  8. WshShell.RegWrite "HKLM\SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\StatusUpdateEnabled",1,"REG_DWORD"
  9. WshShell.RegWrite "HKLM\SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\StatusUpdateInterval",10,"REG_DWORD"
  10. WshShell.RegWrite "HKLM\SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\HP1022-4ALL\Double Spool",0,"REG_DWORD"
  11. WshShell.RegWrite "HKLM\SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\HP1022-4ALL\HostName","","REG_SZ"
  12. WshShell.RegWrite "HKLM\SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\HP1022-4ALL\PortNumber",515,"REG_DWORD"
  13. WshShell.RegWrite "HKLM\SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\HP1022-4ALL\Protocol",2,"REG_DWORD"
  14. WshShell.RegWrite "HKLM\SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\HP1022-4ALL\Queue","ltp1","REG_SZ"
  15. WshShell.RegWrite "HKLM\SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\HP1022-4ALL\HWAddress","","REG_SZ"
  16. WshShell.RegWrite "HKLM\SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\HP1022-4ALL\IPAddress","192.168.0.10","REG_SZ"
  17. WshShell.RegWrite "HKLM\SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\HP1022-4ALL\SNMP Community","public","REG_SZ"
  18. WshShell.RegWrite "HKLM\SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\HP1022-4ALL\Version",1,"REG_DWORD"
  19. WshShell.RegWrite "HKLM\SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\HP1022-4ALL\SNMP Enabled",0,"REG_DWORD"
  20. WshShell.RegWrite "HKLM\SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\HP1022-4ALL\SNMP Index",1,"REG_DWORD"

  21. '取消 “启用双向支持”的勾选
  22. WshShell.RegWrite "HKLM\SYSTEM\CurrentControlSet\Control\Print\Printers\HP LaserJet 1022(大办公室共用)\Attributes",512,"REG_DWORD"
  23. WshShell.RegWrite "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Print\Printers\HP LaserJet 1022(大办公室共用)\Attributes",512,"REG_DWORD"

  24. '添加打印机端口信息
  25. WshShell.RegWrite "HKLM\SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\HP3500\HWAddress","","REG_SZ"
  26. WshShell.RegWrite "HKLM\SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\HP3500\HostName","","REG_SZ"
  27. WshShell.RegWrite "HKLM\SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\HP3500\Protocol",1,"REG_DWORD"
  28. WshShell.RegWrite "HKLM\SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\HP3500\Version",1,"REG_DWORD"
  29. WshShell.RegWrite "HKLM\SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\HP3500\IPAddress","192.168.0.116","REG_SZ"
  30. WshShell.RegWrite "HKLM\SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\HP3500\PortNumber","9100","REG_DWORD"
  31. WshShell.RegWrite "HKLM\SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\HP3500\SNMP Community","public","REG_SZ"
  32. WshShell.RegWrite "HKLM\SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\HP3500\SNMP Enabled",1,"REG_DWORD"
  33. WshShell.RegWrite "HKLM\SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\HP3500\SNMP Index",1,"REG_DWORD"

  34. '安装打印机驱动
  35. WshShell.Run "Rundll32.exe printui.dll,PrintUIEntry /if /b ""HP LaserJet 1022(大办公室共用)"" /f \\dc1\PrintDrivers\HP1022\HPLJ1020.inf /r ""HP1022-4ALL"" /m ""HP

  36. LaserJet 1022"""
  37. WshShell.Run "Rundll32.exe printui.dll,PrintUIEntry /if /b ""HP LaserJet 3500(大办公室业务)"" /f \\dc1\PrintDrivers\HP3500(x86)\hpc3500e.inf /r ""HP3500"" /m ""HP

  38. Color LaserJet 3500"""

  39. '刷新打印服务
  40. WshShell.Run "net stop spooler",0,true
  41. WshShell.run "net start spooler",0,true
复制代码
回复

使用道具 举报

9#
 楼主| 发表于 2011-2-25 14:41:44 | 只看该作者

  1. Set colPrinters = objWMIService.ExecQuery ("Select * From Win32_Printer")
复制代码

已经查询出现有的打印机了,现在,如何判定是否已经存在这两个打印机:
HP LaserJet 1022(大办公室共用)
HP LaserJet 3500(大办公室业务)
如果没有刚安装,有则退出。
回复

使用道具 举报

10#
 楼主| 发表于 2011-2-25 14:46:25 | 只看该作者
最好加入操作系统不同,如32位,64位,而指向不同的驱动程序位置。
这样就方便多了。
回复

使用道具 举报

11#
发表于 2011-2-25 15:57:05 | 只看该作者
1.如果不存在应该查不到的吧????
2.判断系统可以使用环境变量PROCESSOR_ARCHITECTURE
如果是x86就是32位的,否则是64位.
回复

使用道具 举报

12#
 楼主| 发表于 2011-2-25 17:09:16 | 只看该作者

回复 #11 chenall 的帖子

1、是的,但不知怎样从colPrinters里判断是否存在打印机
2、谢谢

  1. C:\>echo %PROCESSOR_ARCHITECTURE%
  2. AMD64
复制代码
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|捐助支持|无忧启动 ( 闽ICP备05002490号-1 )

闽公网安备 35020302032614号

GMT+8, 2024-11-17 03:09

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表