why dont u add a network printer like u usually do in windows? just add a local printer on the port tcp/ip and add in your IP.
REG ADD "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\HPprinter" /v HostName /t REG_SZ /d HPprinter
REG ADD "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\HPprinter" /v HWAddress /t REG_SZ
REG ADD "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\HPprinter" /v IPAddress /t REG_SZ /d 172.20.100.150
REG ADD "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\HPprinter" /v PortNumber /t REG_DWORD /d 9100
REG ADD "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\HPprinter" /v Protocol /t REG_DWORD /d 1
REG ADD "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\HPprinter" /v Version /t REG_DWORD /d 1
REG ADD "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\HPprinter" /v "SNMP Community" /t REG_SZ /d public
REG ADD "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\HPprinter" /v "SNMP Enabled" /t REG_DWORD /d 1
REG ADD"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\HPprinter" /v "SNMP Index" /t REG_DWORD /d 1
rundll32 printui.dll,PrintUIEntry /if /b "HPprinter" /f "c:\WINDOWS\inf\ntprint.inf" /r "HPprinter" /m "HP LaserJet 4100 Series PCL6"
Really no one has any idea how to setup a tcp / ip printer in windows 7 from command line?
Really no one has any idea how to setup a tcp / ip printer in windows 7 from command line?
found this, there is a little bit of info for win7,it may or maynot be of use Command Line Printer Control![]()
Really no one has any idea how to setup a tcp / ip printer in windows 7 from command line?
found this, there is a little bit of info for win7,it may or maynot be of use Command Line Printer Control![]()
' Add Local Printer v2.1
' Programmed by WindowsStar - Copyright (c) 2008-2010
' ---------------------------------------------------
On Error Resume Next
Set WShNetwork = CreateObject("WScript.Network")
Set WShShell = WScript.CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")
Set objEnv = WshShell.Environment("Process")
Title = "Printer Name"
Message = "Name of Printer." & vbLF & vbLF & "Leave blank or press cancel to quit."
strPrinter = InputBox(Message, Title)
If strPrinter = "" Then Wscript.quit
Title = "Printer Driver Name"
Message = "Printer Driver Name." & vbLF & vbLF & "Leave blank or press cancel to quit."
strDriverName = InputBox(Message, Title)
If strDriverName = "" Then Wscript.quit
Title = "Port Name"
Message = "Enter the port you want to use." & vbLF & vbLF & "Enter and IP address (i.e. 192.168.1.1)" & vbLF & "OR Enter LPT1: for parallel printing." & vbLF & vbLF & "Leave blank or press cancel to quit."
strPort = InputBox(Message, Title)
If strPort = "" Then Wscript.quit
strComputer = "."
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set objPrinter = objWMIService.Get("Win32_Printer").SpawnInstance_
objPrinter.DriverName = strDriverName
objPrinter.PortName = strPort
objPrinter.DeviceID = strPrinter
objPrinter.Location = ""
objPrinter.Network = False
objPrinter.Shared = False
objPrinter.ShareName = ""
objPrinter.Put_
WshShell.Popup " Done!",5,"Script Message"
I wrote this script (VBScript) a long time ago for adding a printer to Windows XP machines. I tested it and it works on Windows 7. I tweaked it a bit to take the bare minimum input. The biggest problem with it is that you have to know the EXACT name of the driver or the script will fail. If you know all this information and know it well then the script will help you add 2 or 3 printers quickly.
Example use:
Printer Name: HP LaserJet 4500N
Printer Driver Name: HP LaserJet 4500 series PCL6
Port Name: 192.168.1.200
You must have the Printer Driver Name exactly correct or it will fail. If the IP address is wrong or the computer cannot access the IP address this script will fail.
Please NOTE there is no error checking.
If you have the printer shared off a server there is a much better way of doing this and I have a different script for that let me know.
Here it is: (Copy and paste in Notepad, save as "AddPrinter.vbs") or Download below.
Code:' Add Local Printer v2.1 ' Programmed by WindowsStar - Copyright (c) 2008-2010 ' --------------------------------------------------- On Error Resume Next Set WShNetwork = CreateObject("WScript.Network") Set WShShell = WScript.CreateObject("WScript.Shell") Set fso = CreateObject("Scripting.FileSystemObject") Set objEnv = WshShell.Environment("Process") Title = "Printer Name" Message = "Name of Printer." & vbLF & vbLF & "Leave blank or press cancel to quit." strPrinter = InputBox(Message, Title) If strPrinter = "" Then Wscript.quit Title = "Printer Driver Name" Message = "Printer Driver Name." & vbLF & vbLF & "Leave blank or press cancel to quit." strDriverName = InputBox(Message, Title) If strDriverName = "" Then Wscript.quit Title = "Port Name" Message = "Enter the port you want to use." & vbLF & vbLF & "Enter and IP address (i.e. 192.168.1.1)" & vbLF & "OR Enter LPT1: for parallel printing." & vbLF & vbLF & "Leave blank or press cancel to quit." strPort = InputBox(Message, Title) If strPort = "" Then Wscript.quit strComputer = "." Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set objPrinter = objWMIService.Get("Win32_Printer").SpawnInstance_ objPrinter.DriverName = strDriverName objPrinter.PortName = strPort objPrinter.DeviceID = strPrinter objPrinter.Location = "" objPrinter.Network = False objPrinter.Shared = False objPrinter.ShareName = "" objPrinter.Put_ WshShell.Popup " Done!",5,"Script Message"
I wrote this script (VBScript) a long time ago for adding a printer to Windows XP machines. I tested it and it works on Windows 7. I tweaked it a bit to take the bare minimum input. The biggest problem with it is that you have to know the EXACT name of the driver or the script will fail. If you know all this information and know it well then the script will help you add 2 or 3 printers quickly.
Example use:
Printer Name: HP LaserJet 4500N
Printer Driver Name: HP LaserJet 4500 series PCL6
Port Name: 192.168.1.200
You must have the Printer Driver Name exactly correct or it will fail. If the IP address is wrong or the computer cannot access the IP address this script will fail.
Please NOTE there is no error checking.
If you have the printer shared off a server there is a much better way of doing this and I have a different script for that let me know.
Here it is: (Copy and paste in Notepad, save as "AddPrinter.vbs") or Download below.
Code:' Add Local Printer v2.1 ' Programmed by WindowsStar - Copyright (c) 2008-2010 ' --------------------------------------------------- On Error Resume Next Set WShNetwork = CreateObject("WScript.Network") Set WShShell = WScript.CreateObject("WScript.Shell") Set fso = CreateObject("Scripting.FileSystemObject") Set objEnv = WshShell.Environment("Process") Title = "Printer Name" Message = "Name of Printer." & vbLF & vbLF & "Leave blank or press cancel to quit." strPrinter = InputBox(Message, Title) If strPrinter = "" Then Wscript.quit Title = "Printer Driver Name" Message = "Printer Driver Name." & vbLF & vbLF & "Leave blank or press cancel to quit." strDriverName = InputBox(Message, Title) If strDriverName = "" Then Wscript.quit Title = "Port Name" Message = "Enter the port you want to use." & vbLF & vbLF & "Enter and IP address (i.e. 192.168.1.1)" & vbLF & "OR Enter LPT1: for parallel printing." & vbLF & vbLF & "Leave blank or press cancel to quit." strPort = InputBox(Message, Title) If strPort = "" Then Wscript.quit strComputer = "." Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set objPrinter = objWMIService.Get("Win32_Printer").SpawnInstance_ objPrinter.DriverName = strDriverName objPrinter.PortName = strPort objPrinter.DeviceID = strPrinter objPrinter.Location = "" objPrinter.Network = False objPrinter.Shared = False objPrinter.ShareName = "" objPrinter.Put_ WshShell.Popup " Done!",5,"Script Message"
Thanks for the help. I figured it out though. All you have to do is run this command first.
Cscript %windir%/System32/Printing_Admin_Scripts/en-US/Prnport.vbs -a -r IP_10.2.3.4 -h 10.2.3.4
rundll32 printui.dll,PrintUIEntry /if /b "Test Printer" /f %windir%\inf\ntprint.inf /r "IP_10.2.3.4" /m "HP Laserjet 4100 Series PCL6"
The first script just adds the port to Windows 7/Vista the second creates the printer. Running the first script wasn't needed in XP.
Thanks for your help.
Here's the script:
::==============================================
::Written by Matt Lieblong Copyright 2009-2010
@ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION
SET P1=%AestheticNameOfPrinter
SET PIP1=%1x.x.x.x
SET PNAME1=%"TOSHIBA eS452/453Series PCL6"
SET PDRIVER1=%"[URL="file://localsitepcname/PRINTERDRIVERS/352-353-452-453/eB4ox2.inf"]\\LocalSitePCname\PRINTERDRIVERS\352-353-452-453\eB4ox2.inf[/URL]"
SET P2=%AestheticNameOfPrinter2
SET PIP2=%1x.x.x.x
SET PNAME2=%"TOSHIBA e-STUDIO Series Fax"
SET PDRIVER2=%"[URL="file://localsitepcname/PRINTERDRIVERS/ALLMODELSLANFAX/eS4cfx2k.inf"]\\LocalSitePCname\PRINTERDRIVERS\ALLMODELSLANFAX\eS4cfx2k.inf[/URL]"
SET P3=%AestheticNameOfPrinter3
SET PIP3=%1x.x.x.x
SET PNAME3=%"TOSHIBA eS452/453Series PCL6"
SET PDRIVER3=%"[URL="file://localsitepcname/PRINTERDRIVERS/352-353-452-453/eB4ox2.inf"]\\LocalSitePCname\PRINTERDRIVERS\352-353-452-453\eB4ox2.inf[/URL]"
FOR %%N IN (1 2 3) DO (
SET P=!P%%N%!
FIND | REG QUERY "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Printers\!P!"
IF ERRORLEVEL 1 (
SET PIP=!PIP%%N%!
SET PNAME=!PNAME%%N%!
SET PDRIVER=!PDRIVER%%N%!
ECHO !P!
ECHO !PIP!
ECHO !PNAME!
ECHO !PDRIVER!
cscript.exe c:\windows\system32\prnport.vbs -a -r !P! -h !PIP! -o raw -n 9100
rundll32 printui.dll PrintUIEntry /if /b !P! /f !PDRIVER! /r !P! /m !PNAME! /z
)
)
::END OF SCRIPT, AFTER CUSTOMIZING FOR A SITE, DELETE EVERYTHING PAST THIS LINE
::THE FOLLOWING IS LOCAL PRINTER VARIABLE TEMPLATE INFO
::DEFINE A MASTER DRIVER FOLDER, FROM WHICH TO COPY THE VARIOUS MODEL'S INFO
::TO A PRINTER VARIABLE DECLARATION ABOVE (THIS JUST SPEEDS UP WRITING MULTIPLE
::SCRIPTS). ONCE SCRIPT IS WRITTEN, DELETE THIS PARAGRAPH AND EVERYTHING BELOW,
::NAME FILE AS PRNSITENAME.BAT OR SIMILAR TO BE SAVED IN DOMAIN sysvol OR policy
::FOLDERS.
::202-203-232-233-282-283
:: TOSHIBA eS282/283Series PCL6
:: \PRINTERDRIVERS\202-203-232-233-282-283\eB2ox2.inf
::
::352-353-452-453
::TOSHIBA eS452/453Series PCL6
::\PRINTERDRIVERS\352-353-452-453\eB4ox2.inf
::
::520-523-600-603-720-723-850-853
:: TOSHIBA eS850/853Series PCL6
:: \PRINTERDRIVERS\520-523-600-603-720-723-850-853\eB8mx2.inf
::
::205-255-305-355-455
::TOSHIBA e-STUDIO455Series PCL6
:: \PRINTERDRIVERS\205-255-305-355-455\eS4px2.inf
::
::ALLMODELSLANFAX (for all toshiba models' print-to-fax feature)
:: TOSHIBA e-STUDIO Series Fax
:: \PRINTERDRIVERS\ALLMODELSLANFAX\eS4cfx2k.inf
::
::Dell1710n
:: Dell Laser Printer 1710n
:: \PRINTERDRIVERS\Dell1710n\DKAAY2DA.inf
::
::Dell1720dn
:: Dell Laser Printer 1720dn
:: \PRINTERDRIVERS\Dell1720dn\c.inf (yes the file is named c.inf)
::
::Dell2330dn
:: Dell 2330d Laser Printer
:: \PRINTERDRIVERS\Dell2330dn\DKACHL40.inf
::
::Dell2335dn
:: Dell 2335dn MFP
::\PRINTERDRIVERS\Dell2335dn\sdf1m.inf
::
::Dell3130c
:: Dell 3130cn Color Laser PCL6
:: \PRINTERDRIVERS\Dell3130c\dlxbmzi.inf
::
::Lexmark T630-T632
:: Lexmark T630
:: OR
:: Lexmark T632
:: \PRINTERDRIVERS\LexmarkT630-T632\lmaaga40.inf
::
::HP OfficeJet Pro L7700
:: HP Officejet Pro L7700 Series BT
::
::
::TEMPLATE TO MACHINE INSTALL A LOCALLY SHARED PRINTER ON ANOTHER MACHINE
::SO FAR TESTS REQUIRE NO INSTALL CHECK, AS IT WILL NOT INSTALL DUPLICATES
::IF ALREADY INSTALLED...
::LOCAL SHARE OF HP4 PRINTER INSTALL on computer [computername] used by [users name]:
:: RUNDLL32 PRINTUI.DLL PrintUIEntry /ga /in /n\\computername\printersharename
::TO DELETE A LOCALLY INSTALLED PRINTER (WHICH IS WHAT THE ABOVE SCRIPT INSTALLS)
:: RUNDLL32 PRINTUI.DLL PrintUIEntry /dl /n "printername" /q
::NOTES ON USING THIS SCRIPT:
::THIS SCRIPT IS IDEAL FOR AUTOMATICALLY INSTALLING PRINTERS ACROSS VARIOUS WAN SITES
::USING GP/GPO FEATURES. USEFUL FOR THOSE WHO HAVE NUMEROUS WAN SITES, BUT NOT PRINT
::SERVERS AT ALL WAN SITES, ESPECIALLY WITH SLOW CONNECTIONS TO A CENTRAL HUB OR MAIN
::PRINT SERVER. TO USE THIS SCRIPT, YOU MUST USE/SETUP THE FOLLOWING:
::
::1. ACTIVE DIRECTORY/GROUP POLICY FUNCTIONALITY
::2. AD ORGANIZATIONAL UNIT FOR EACH WAN SITE, WITH ALL RESPECTIVE PC'S ASSIGNED WITHIN
::3. GPO FOR EACH SITE, WITH ONLY ONE SETTING: ASSIGN MACHINE STARTUP SCRIPT WITH
:: RESPECTIVE WAN SITE'S UNIQUE SCRIPT LISTED
::4. GPO TO ENABLE THE "UNSIGNED DRIVER INSTALLATION BEHAVIOR" TO "SILENTLY SUCCEED",
:: THIS GPO IS MOST SIMPLY ASSIGNED TO THE OU CONTAINING ALL WAN OU'S, OR COULD
:: BE INCORPORATED INTO EACH WAN SITE'S STARTUP SCRIPT GPO.
::5. FOR SITUATIONS WITH SLOW LINKS BETWEEN WAN SITES AND CENTRAL HUB FILESERVERS,
:: CREATE A "PRINTERDRIVER" SHARE ON ONE COMPUTER AT EACH WAN SITE, FROM WHICH
:: TO SERVE THE INF-BASED LOCAL PRINTER INSTALLATIONS. THIS SPEEDS UP DRIVER
:: DOWNLOADS SIGNIFICANTLY, AND HAS LITTLE EFFECT ON SHARING PC OVERALL.
::
::I WROTE THIS AS I COULD FIND NOTHING SIMILAR ELSEWHERE. IT'S ALL IN BATCH, IT'S QUITE
::RUDIMENTARY, HOWEVER IN MY CASE, I WAS ABLE TO WRITE AND DEPLOY THIS TO ~70 WAN SITES,
::WITHIN A WEEK USING THIS SCRIPT. MUCH EASIER AND FASTER IN THE LONG RUN THAN RUNNING
::A PRINT SERVER, IT CREATES IP PORTS AND LOCALLY INSTALLS NETWORK PRINTERS. PRINTERS CAN
::BE INSTALLED, MODIFIED, AND DELETED ALL WITHIN THE SCRIPT. THE INSTALL LOOP CONTAINS
::A REGISTRY CHECK TO DETERMINE IF A PRINTER HAS BEEN INSTALLED ALREADY AT THE REGISTRY
::LEVEL. INITIAL INSTALL TAKES A FEW SECONDS PLUS TIME TO COPY/DOWNLOAD THE DRIVER FROM
::YOUR LOCAL PRINTERDRIVER SHARE, PER PRINTER INSTALL. OVER A COMMON 10/100 SWITCH IT
::TAKES ABOUT 5-10 SECONDS FOR LARGER (7MB) MFP PRINTER DRIVERS.
::
::IF YOU ESTIMATE 5 MINUTES PER INSTALL, THIS ENABLED ME TO INSTALL ALL NETWORK OR SHARED
::PRINTERS AT OVER 70 WAN SITES WITH ABOUT 1 WEEKS WORTH OF WORK. EQUIVALENT TO SEVERAL
::MONTHS TIME IF PERFORMING MANUAL INSTALLS OF SAME PRINTERS.
WindowsStar thats a nice vbs script, but it appears to be a one-off approach. I run a network with over 50 WAN sites in our XP workstation environment, and have developed a looping prnport.vbs/printui.dll machine startup script run via GPO that is easily customizeable to install anywhere from one to dozens of printers at each site.
But it doesn't want to work in W7. please help