Need help adding TCP/IP Printer through Script

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."
3 answers Last reply
More about need adding printer script
  1. 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."
  2. > '******** 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
  3. Necropost
Ask a new question

Read More

TCP/IP Printers Windows