Sign in with
Sign up | Sign in
Your question

Trying to add IP printer using a bat file

Last response: in Windows XP
Share
August 18, 2005 7:36:02 PM

Archived from groups: microsoft.public.windowsxp.general (More info?)

I am having a problem with installing a printer using a bat file. I run the
bat, all of the keys are created. They look fine. The drivers are then
copied, but then I receive an error: Operation could not be completed. The
specified port is unknown.

Any ideas?

Here is the code.
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 5000 Series PCL"

More about : add printer bat file

Anonymous
a b C Monitor
August 19, 2005 4:35:28 AM

Archived from groups: microsoft.public.windowsxp.general (More info?)

In news:C1073BF5-6F0A-4C27-B2BF-458A175A3FA9@microsoft.com,
skitzsofrenick <skitzsofrenick@discussions.microsoft.com> typed:
> I am having a problem with installing a printer using a bat file. I
> run the bat, all of the keys are created. They look fine. The drivers
> are then copied, but then I receive an error: Operation could not be
> completed. The specified port is unknown.
>
> Any ideas?

<snip>
>
Perhaps this is a dumb question, but have you tried using something like
Con2prt.exe to install network printers?
August 19, 2005 2:12:02 PM

Archived from groups: microsoft.public.windowsxp.general (More info?)

Never heard of this util. I will look it up and let you know if how that works.

Basically we are trying to create a simplified util to creating IP printers
for some visitors. Its always easiest to make it as simple as possible for
some people.
Related resources
August 19, 2005 2:21:02 PM

Archived from groups: microsoft.public.windowsxp.general (More info?)

This utility looks like its a WindowsNT util and not made avail for XP. Is
this true?
Anonymous
a b C Monitor
August 21, 2005 12:19:20 AM

Archived from groups: microsoft.public.windowsxp.general (More info?)

skitzsofrenick wrote:

> This utility looks like its a WindowsNT util and not made
> avail for XP. Is this true?
Hi,

Another alternative is to use the prnadmin.dll that comes with the
MS Windows 2003 Server Resource Kit.

With prnadmin.dll you can e.g. do the following port handling from
e.g. VBScript:

- Adding/deleting ports (standard local ports, TCP LPR/RAW ports)
(local or remote)

Windows Server 2003 Resource Kit Tools
http://www.microsoft.com/downloads/details.aspx?FamilyI...

(The kit will install on WinXP or later, but you can copy needed
files over to other computers, and then run regsvr32.exe against
prnadmin.dll)


More about PrnAdmin (from the RK help file):

Printer Administration Objects (PrnAdmin) is a COM-based tool that
provides large-scale, noninteractive control of printers, drivers,
and ports on local and remote computers.

Using PrnAdmin, you can:

Add and delete a local or remote printer.
Add and delete printer connections.
Add and delete a local or remote form.
Add and delete a local or remote standard TCP/IP port (of type
Line Printer Remote (LPR) or RAW).
Add and delete a local or remote driver.
View a list of printers, ports, drivers, and forms on a local or
remote computer.
Control and configure a local or remote printer.


PrnAdmin consists of several scriptable COM objects residing in
Prnadmin.dll, which functions as a wrapper around Printui.dll.
Several Microsoft Visual Basic Script (VBScript) sample files are
included with the tool.

Note

For more detailed information on how to use PrnAdmin.DLL, see
Prnadmin.doc. This white paper provides additional information on
printer, drivers, ports and forms to help administrators and
programmers manage a large number of local and remote printers.

Corresponding Operating System Features

All the functionality of prnadmin.dll can be duplicated using the
printers folder and various wizards. Converting printer ports from
LPR to Standard TCP/IP is the only functionality in prnadmin.dll
for which there is no corresponding GUI.

For more information about PrnAdmin and the Windows Management
Instrumentation (WMI) scripts in Windows Server 2003, see
Designing and Deploying Print
Servers(http://go.microsoft.com/fwlink/?LinkID=4745) in the
Windows Server 2003 Deployment Kit.


Files Required

Prnadmin.dll

The following sample VBScript files are also included:

Prnadmin.doc
Clean.vbs
Clone.vbs (there is no WMI equivalent for the cloning script)
Conall.vbs
Defprn.vbs
Drvmgr.vbs
Forms.vbs
Persist.vbs
Portconv.vbs
Portmgr.vbs
Prncfg.vbs
Prnctrl.vbs
Prndata.vbs
Prnmgr.vbs


and

HOW TO: Programmatically Create a Printer and Printer Port by
Using PrinterAdmin (Prnadmin.dll) with a Visual Basic Script
in Microsoft Windows 2000
http://support.microsoft.com/default.aspx?scid=kb;en-us;321025



--
torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of
the 1328 page Scripting Guide:
http://www.microsoft.com/technet/scriptcenter/default.m...
!