No announcement yet.

Add IP Printer?

  • Filter
  • Time
  • Show
Clear All
new posts

  • Add IP Printer?

    How is it possible to add an IP based printer to the computer locally?

    so I have a printer with an IP. I want to install it on my local computer. how can I do this using WMI/VBScript?

  • #2
    Re: Add IP Printer?

    Samples for creating the script:

    - objNewPort.Protocol = [1= RAW, 2=LPR]
    - objNewPort.PortNumber = [If you use TCP raw, specifies the port number for a TCP raw printer port. By default, this is port number 9100.]

    use the command-line tools shipped with Windows xp and newer,
    • Prnport.vbs (Creates or deletes standard TCP/IP printer ports)
    • Prndrvr.vbs (Adds or deletes printer drivers
    • Prnmngr.vbs (Adds or deletes printer connections)


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


    ** Remember to give credit where credit's due **
    and leave Reputation Points for meaningful posts


    • #3
      Re: Add IP Printer?

      Thanks Rems

      yes I followed that but its not working or im not understanding it well. (oh...i dont want to use the command line tools either...not for this project)

      how does it actually work? I mean do we create a port first? (I can create this fine) but then how do we create the printer object saying that the IP of the printer is xx.xx.xx.xx so then it adds it in the printers control panel?

      like in Windows for example when we go through the wizard, we can tell it the host will then automatically install the printer locally on the computer to which we can print to that IP printer
      Last edited by firehawk; 19th March 2008, 22:38.


      • #4
        Re: Add IP Printer?

        Are the drivers for the IP printer already on the computer (either within the default drivers or placed there by you), or do you also need a script to install the drivers?

        And just out of curiousity, is there a reason why you don't have the IP printer installed on a server and then shared out?

        Google (OUR FRIEND) showed me these links that may help you out:
        ** Remember to give credit where credit is due and leave reputation points where appropriate **


        • #5
          Re: Add IP Printer?

          basically we are creating a web admin page to admin a server. The user can either enter a shared network printer and add it (WMI then adds it) or can enter an IP Address of a printer, which I then want to add to the computer using WMI


          • #6
            Re: Add IP Printer?

            A project that I was involved with about 2.5 years ago was simplified using mostly BATch files and VBScript files.

            To add printers with an IP script, you have to perform the following steps.
            1. Create registry entry in text file.
            2. Stop Print Spooler
            3. Import registry file
            4. Start Print Spooler.

            The process went similar to this:

            REM Printer install
            if not exist "%startdir%\temp\printer_ports.reg" call "%startdir%\create_ports.bat"
            net stop "Print Spooler"
            echo Importing registry file...
            REGEDIT.EXE /s "%startdir%\temp\printer_ports.reg"
            net start "Print Spooler"

            @echo off
            if not exist "%startdir%\temp" mkdir "%startdir%\temp"
            echo Windows Registry Editor Version 5.00 > "%startdir%\temp\printer_ports.reg"
            echo. >> "%startdir%\temp\printer_ports.reg"
            echo [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Contro l\Print\Monitors\Standard TCP/IP Port] >> "%startdir%\temp\printer_ports.reg"
            echo. >> "%startdir%\temp\printer_ports.reg"
            echo "Driver"="tcpmon.dll" >> "%startdir%\temp\printer_ports.reg"
            echo. >> "%startdir%\temp\printer_ports.reg"
            echo [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Contro l\Print\Monitors\Standard TCP/IP Port\Ports] >> "%startdir%\temp\printer_ports.reg"
            echo "StatusUpdateInterval"=dword:0000000a >> "%startdir%\temp\printer_ports.reg"
            echo "StatusUpdateEnabled"=dword:00000001 >> "%startdir%\temp\printer_ports.reg"

            echo Creating printer ports... but I need some information
            set /p printerip=Enter single printer IP address or press "x" to quit:
            if /i "%printerip%"=="x" goto endPrintLoop
            echo [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Contro l\Print\Monitors\Standard TCP/IP Port\Ports\IP_%printerip%] >> "%startdir%\temp\printer_ports.reg"
            echo "Protocol"=dword:00000001 >> "%startdir%\temp\printer_ports.reg"
            echo "Version"=dword:00000001 >> "%startdir%\temp\printer_ports.reg"
            echo "HostName"="" >> "%startdir%\temp\printer_ports.reg"
            echo "IPAddress"="%printerip%" >> "%startdir%\temp\printer_ports.reg"
            echo "HWAddress"="" >> "%startdir%\temp\printer_ports.reg"
            echo "PortNumber"=dword:0000238c >> "%startdir%\temp\printer_ports.reg"
            echo "SNMP Community"="public" >> "%startdir%\temp\printer_ports.reg"
            echo "SNMP Enabled"=dword:00000001 >> "%startdir%\temp\printer_ports.reg"
            echo "SNMP Index"=dword:00000001 >> "%startdir%\temp\printer_ports.reg"

            echo Printer information stored...
            goto startPrintLoop


            You then add the printer.

            The complete set of scripts that I created runs from a thumb drive initially. It takes a computer and sets it up as a host with a shared folder. I then access that shared folder from another PC where the user's files and settings get copied to the shared folder. I remove that PC and replace it with a new one, do the initial Windows set up, and then run another script that joins it to the domain, adds printers, certain programs, and much more. It was very specific to the project I was working on, so I can't post much of the code without serious editing. But the above batch files were essential for making the whole project much easier. The first PC took about an hour and a half, while each additional PC took about 45 minutes or less. Without scripts, it was about 2.5-3.5 hours per PC, so there were significant cost savings.
            Last edited by Civisi; 1st April 2008, 21:18. Reason: being more specific.