|
8#
楼主 |
发表于 2011-2-25 14:40:11
|
只看该作者
回复 #6 chenall 的帖子
现在还有问题,就是下面这个代码,会重复添加,能否加入个判断,先确定是否存在,如果不存在,则再安装。
- strComputer = "."
- Set objWMIService = GetObject("winmgmts:\" & strComputer & "\root\cimv2")
- Set colPrinters = objWMIService.ExecQuery ("Select * From Win32_Printer")
- Dim WshShell
- Set WshShell=WScript.CreateObject("WScript.Shell")
- '添加打印机端口信息
- WshShell.RegWrite "HKLM\SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\LprAckTimeout",180,"REG_DWORD"
- WshShell.RegWrite "HKLM\SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\StatusUpdateEnabled",1,"REG_DWORD"
- WshShell.RegWrite "HKLM\SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\StatusUpdateInterval",10,"REG_DWORD"
- WshShell.RegWrite "HKLM\SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\HP1022-4ALL\Double Spool",0,"REG_DWORD"
- WshShell.RegWrite "HKLM\SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\HP1022-4ALL\HostName","","REG_SZ"
- WshShell.RegWrite "HKLM\SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\HP1022-4ALL\PortNumber",515,"REG_DWORD"
- WshShell.RegWrite "HKLM\SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\HP1022-4ALL\Protocol",2,"REG_DWORD"
- WshShell.RegWrite "HKLM\SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\HP1022-4ALL\Queue","ltp1","REG_SZ"
- WshShell.RegWrite "HKLM\SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\HP1022-4ALL\HWAddress","","REG_SZ"
- WshShell.RegWrite "HKLM\SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\HP1022-4ALL\IPAddress","192.168.0.10","REG_SZ"
- WshShell.RegWrite "HKLM\SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\HP1022-4ALL\SNMP Community","public","REG_SZ"
- WshShell.RegWrite "HKLM\SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\HP1022-4ALL\Version",1,"REG_DWORD"
- WshShell.RegWrite "HKLM\SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\HP1022-4ALL\SNMP Enabled",0,"REG_DWORD"
- WshShell.RegWrite "HKLM\SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\HP1022-4ALL\SNMP Index",1,"REG_DWORD"
- '取消 “启用双向支持”的勾选
- WshShell.RegWrite "HKLM\SYSTEM\CurrentControlSet\Control\Print\Printers\HP LaserJet 1022(大办公室共用)\Attributes",512,"REG_DWORD"
- WshShell.RegWrite "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Print\Printers\HP LaserJet 1022(大办公室共用)\Attributes",512,"REG_DWORD"
- '添加打印机端口信息
- WshShell.RegWrite "HKLM\SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\HP3500\HWAddress","","REG_SZ"
- WshShell.RegWrite "HKLM\SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\HP3500\HostName","","REG_SZ"
- WshShell.RegWrite "HKLM\SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\HP3500\Protocol",1,"REG_DWORD"
- WshShell.RegWrite "HKLM\SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\HP3500\Version",1,"REG_DWORD"
- WshShell.RegWrite "HKLM\SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\HP3500\IPAddress","192.168.0.116","REG_SZ"
- WshShell.RegWrite "HKLM\SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\HP3500\PortNumber","9100","REG_DWORD"
- WshShell.RegWrite "HKLM\SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\HP3500\SNMP Community","public","REG_SZ"
- WshShell.RegWrite "HKLM\SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\HP3500\SNMP Enabled",1,"REG_DWORD"
- WshShell.RegWrite "HKLM\SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\HP3500\SNMP Index",1,"REG_DWORD"
- '安装打印机驱动
- WshShell.Run "Rundll32.exe printui.dll,PrintUIEntry /if /b ""HP LaserJet 1022(大办公室共用)"" /f \\dc1\PrintDrivers\HP1022\HPLJ1020.inf /r ""HP1022-4ALL"" /m ""HP
- LaserJet 1022"""
- WshShell.Run "Rundll32.exe printui.dll,PrintUIEntry /if /b ""HP LaserJet 3500(大办公室业务)"" /f \\dc1\PrintDrivers\HP3500(x86)\hpc3500e.inf /r ""HP3500"" /m ""HP
- Color LaserJet 3500"""
- '刷新打印服务
- WshShell.Run "net stop spooler",0,true
- WshShell.run "net start spooler",0,true
复制代码 |
|