diamond Posted August 24, 2005 Posted August 24, 2005 I've done some searching on the forums, and have yet to find a good way to do the following at part of an unattended / WPI installer. Say I have a printer that has a JetDirect card on 10.10.10.14. Let's say it's an HP Laserjet 4000. Is there any way to script the installation of this printer so that you have the HPLJ 4000 printing to port TCP/IP 10.10.10.14, and not just a network map to it?I've found the following information regarding it:Make network port:RunDLL32.EXE tcpmonui.dll,LocalAddPortUI <- this will open the add new TCP/IP port wizard, but I don't know how to do this silently with scripted additionsInstall PrinterRunDLL32.exe printui.dll,PrintUIEntry /ia /m "Hp LaserJet 4000 PCL 5e" /h "Intel" /v "Windows 2000 or XP" /f C:\printers\hp4000pcl5e\hp4000p5.inf <- this will install the driver for the printer (if exists on LPT1) with the inf located in C:\printers. The question would be how to redirect the port to be the one created earlier with the above command so that the printer prints to 10.10.10.14 instead of LPT1.After looking at the rundll32 printui.dll,PrintUIEntry /? screen, I've seen to connect to a UNC printer but not to the TCP/IP port. Any suggestions / help would be appreciated. I've got a couple hundred machines that all printer to different peer printers [so that traffic is not passed through the server] that I need to reload. Adding all these printers manually instead of using RIS/Unattended or WPI/equivalent would take AGES!Thanks in Advance,Diamond
schalti Posted August 24, 2005 Posted August 24, 2005 (edited) Two VBScript examples derived from a script found on the web:Source--> Raw Port 9100, no SNMPSet objWMIService = GetObject("winmgmts:")Set objNewPort = objWMIService.Get _("Win32_TCPIPPrinterPort").SpawnInstance_objNewPort.Name = "IP_192.168.40.20"objNewPort.Protocol = 1objNewPort.HostAddress = "192.168.40.20"objNewPort.PortNumber = "9100"objNewPort.SNMPEnabled = FalseobjNewPort.Put_--> LPR Port, SNMPSet objWMIService2 = GetObject("winmgmts:")Set objNewPort2 = objWMIService2.Get _("Win32_TCPIPPrinterPort").SpawnInstance_objNewPort2.Name = "IP_192.168.40.21"objNewPort2.Protocol = 2objNewPort2.HostAddress = "192.168.40.21"objNewPort2.Queue = "MyQueue"objNewPort2.ByteCount = TrueobjNewPort2.SNMPEnabled = TrueobjNewPort2.SNMPDevIndex = 2objNewPort2.SNMPCommunity = "MySNMP"objNewPort2.Put_Save as <filename>.vbs and start using cscript.exe or wscript.exeThis will create the ports for you.Then use How to add printers with no user interaction in Windows with an example on how to connect to a local IP port.Example:rundll32 printui.dll,PrintUIEntry /if /b "NORTH-US-SRTEST-TEST24-BOGUS" /f %windir%\inf\ntprint.inf /r "IP_192.168.40.20" /m "HP Laserjet 4000 Series PCL" /Z Edited August 24, 2005 by schalti
diamond Posted August 25, 2005 Author Posted August 25, 2005 Just wanted to follow up, Schalti's information is good and works like a champ! I've written some VBS files for a lot of our network printers and have tested it and works with a single click. Thanks Schalti!Just a 'final look', I'm sure this could all be done in vbs, but I've always been more comfortable with batch scripting, so for a static printer, here's an example. This is for an LPR printer, Toshiba 4511 Copier/Printer/Fax to be exact:toshiba.vbs:Set objWMIService2 = GetObject("winmgmts:")Set objNewPort2 = objWMIService2.Get _("Win32_TCPIPPrinterPort").SpawnInstance_objNewPort2.Name = "IP_10.10.10.222"objNewPort2.Protocol = 2objNewPort2.HostAddress = "10.10.10.222"objNewPort2.Queue = "PRINTER"objNewPort2.ByteCount = TrueobjNewPort2.Put_Then to run it unattended from Runonce, Guirunonce, WPI, etc, the installer.cmd file:@REM This will install the TCP/IP port then install the printer and fax machine for the Toshiba Printer.@cscript I:\printers\TOSH3511\tosh.vbs@rundll32 printui.dll,PrintUIEntry /if /b "Toshiba 3511 Printer" /f "I:\printerdrivers\Toshiba 3511print\eS4c5c2k.inf" /r "IP_10.10.10.222" /m "TOSHIBA e-STUDIO4511SeriesPCL5c"@rundll32 printui.dll,PrintUIEntry /if /b "Toshiba 3511 Fax" /f "I:\printerdrivers\Toshiba 3511fax\eS4cfx2K.inf" /r "IP_10.10.10.222" /m "TOSHIBA e-STUDIO Series Fax"Please note that this is from a netinstall, so the drive letters are maps to a shared installation directory. You'd have to change it to local for a CD based install or otherwise.Thanks again for all the help, hope this information helps someone else one day!Diamond
schalti Posted August 25, 2005 Posted August 25, 2005 Three things:- it works only on XP as of now- it fails on 2000 because the needed WMI Class is not implemented- it fails on 2003 because there is some bug or restriction somewhere - currently under investigation -> there are even examples online @M$ that do not work!Using both VBScripts and Shell scripts is fine, some things you can only implement with VBScript, some need considerable less code to implement in a Shell script.
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now