Sign in with
Sign up | Sign in
Your question

Need help adding TCP/IP Printer through Script

Last response: in Windows 2000/NT
Share
Anonymous
October 27, 2004 4:41:04 PM

Archived from groups: microsoft.public.windowsnt.print (More info?)

Want to re-image a pc then add a TCP/IP printer. Below is what I have so far
but keeps adding the IP address as a local port instead of TCP/IP port.
Already tried changing the "oPort.PortType" to other numbers but didn't seem
to work. Any help would be extremely grateful as I'm very very new to
scripts. Thanks so much.


'******** Register prnadmin.dll file on client computer *******

Set WshShell = Wscript.CreateObject("Wscript.Shell")

WshShell.Run "regsvr32 /s \\s1avdc01\Tools\Prnadmin.dll",1,TRUE

'************** Create the port first *******************************

dim oPort

dim oMaster

set oPort = CreateObject("Port.Port.1")

set oMaster = CreateObject("PrintMaster.PrintMaster.1")

oPort.PortName = "IP_192.168.114.20"

oPort.PortType = 1

oMaster.PortAdd oPort

if Err <> 0 then

msgbox "There was an error creating the port."

end if

'********************************************************************

'************** Create the printer second ***************************
'Change MyPrinter to the name of the printer that you are adding.
'Change PrinterDriver to the name of the printer driver that you are adding.


dim oPrinter

set oPrinter = CreateObject("Printer.Printer.1")

oPrinter.PrinterName = "Test" ' name of the printer as it appears in the
Printers folder

oPrinter.DriverName = "HP LaserJet 2100" ' name that is referenced in
ntprint.inf

oPrinter.PortName = "IP_192.168.114.20" ' Specify a port name. Can also
point to LPT or COM port.

oMaster.PrinterAdd oPrinter
If Err <> 0 then

msgbox "There was an error creating the printer."

end if

'********************************************************************

msgbox "The script is finished."
Anonymous
November 1, 2004 8:50:08 PM

Archived from groups: microsoft.public.windowsnt.print (More info?)

Adding a TCP/IP SPM port requires more parameters. Did you try the
portmgr.vbs script? It comes with the reskit and has examples of how to add
SPM ports.

--
Felix Maxa
Windows Printing Team

This posting is provided "AS IS" with no warranties, and confers no rights.


"Steve Phillips" <Steve Phillips@discussions.microsoft.com> wrote in message
news:B0375EF5-4ECD-4F9C-8A83-578C9F3BCE32@microsoft.com...
> Want to re-image a pc then add a TCP/IP printer. Below is what I have so
> far
> but keeps adding the IP address as a local port instead of TCP/IP port.
> Already tried changing the "oPort.PortType" to other numbers but didn't
> seem
> to work. Any help would be extremely grateful as I'm very very new to
> scripts. Thanks so much.
>
>
> '******** Register prnadmin.dll file on client computer *******
>
> Set WshShell = Wscript.CreateObject("Wscript.Shell")
>
> WshShell.Run "regsvr32 /s \\s1avdc01\Tools\Prnadmin.dll",1,TRUE
>
> '************** Create the port first *******************************
>
> dim oPort
>
> dim oMaster
>
> set oPort = CreateObject("Port.Port.1")
>
> set oMaster = CreateObject("PrintMaster.PrintMaster.1")
>
> oPort.PortName = "IP_192.168.114.20"
>
> oPort.PortType = 1
>
> oMaster.PortAdd oPort
>
> if Err <> 0 then
>
> msgbox "There was an error creating the port."
>
> end if
>
> '********************************************************************
>
> '************** Create the printer second ***************************
> 'Change MyPrinter to the name of the printer that you are adding.
> 'Change PrinterDriver to the name of the printer driver that you are
> adding.
>
>
> dim oPrinter
>
> set oPrinter = CreateObject("Printer.Printer.1")
>
> oPrinter.PrinterName = "Test" ' name of the printer as it appears in the
> Printers folder
>
> oPrinter.DriverName = "HP LaserJet 2100" ' name that is referenced in
> ntprint.inf
>
> oPrinter.PortName = "IP_192.168.114.20" ' Specify a port name. Can also
> point to LPT or COM port.
>
> oMaster.PrinterAdd oPrinter
> If Err <> 0 then
>
> msgbox "There was an error creating the printer."
>
> end if
>
> '********************************************************************
>
> msgbox "The script is finished."
March 2, 2010 2:24:15 AM

> '******** Register prnadmin.dll file on client computer *******
>
> Set WshShell = Wscript.CreateObject("Wscript.Shell" )
>
> WshShell.Run "regsvr32 /s \\s1avdc01\Tools\Prnadmin.dll",1,TRUE
Hi. I have same problem.

You have skiped:

oPort.HostAddress = "192.168.114.20"

<code>
dim oPort
dim oMaster

set oPort = CreateObject("Port.Port.1" )
set oMaster = CreateObject("PrintMaster.PrintMaster.1" )

oPort.PortName = "IP_192.168.114.20"

oPort.PortType = 2

oPort.HostAddress = "192.168.114.20"


oMaster.PortAdd oPort


if Err <> 0 then

msgbox "There was an error creating the port."

end if
</code>

> '************** Create the port first *******************************
>
> dim oPort
>
> dim oMaster
>
> set oPort = CreateObject("Port.Port.1" )
>
> set oMaster = CreateObject("PrintMaster.PrintMaster.1" )
>
> oPort.PortName = "IP_192.168.114.20"
>
> oPort.PortType = 1
>
> oMaster.PortAdd oPort
>
> if Err <> 0 then
>
> msgbox "There was an error creating the port."
>
> end if
March 2, 2010 7:19:56 AM

Necropost
!