none
Add printer port type from registry RRS feed

  • Question

  • Hey everybody

    I'm having an issue with adding a new printer port type to the available port list. When I add the port type in the registry, it never appears in the available port type list (Devices and printers --> Print server properties --> Ports --> Add Port)

    In the registry, under "HKLM\SYSTEM\CurrentControlSet\Control\Print\Monitors\" I added a new key "Canon BJNP Port" with the settings from the setup.exe (read with the process explorer from the sysinternals tools). 

    When I do the installation of the port with the Canon Printer setup.exe, it installs the port without any problems. I copied them one to one to my script, installed the canon printer driver in silent mode and added the port manually. The settings are done by a script which gets some information of the printer (automatically). 

    Script with the registry things: 

    function RemovePort {
    
        $path = "HKLM:\System\CurrentControlSet\Control\Print\Monitors"
        if(Test-Path "$path\Canon BJNP Port"){
            Remove-Item -Path "$path\Canon BJNP Port" -Recurse
            New-Item -Path $path -Name "Canon BJNP Port"
        }
        else{
            New-Item -Path $path -Name "Canon BJNP Port"
        }
    }
    
    function AddPort{
            
            Write-Log "Adding port for Canon IP110 series."
            $path = "HKLM:\System\CurrentControlSet\Control\Print\Monitors\Canon BJNP Port"
    
            #Enter Canon Port Information
            New-Item -Path $path -Name "Ports"
            New-ItemProperty -Path $path -Name "PortName Prefix" -Value "CNBJNP_" -PropertyType "String"
            New-ItemProperty -Path $path -Name "PortName FaxPrefix" -Value "CNBJNPFAX_" -PropertyType "String"
            New-ItemProperty -Path $path -Name "BufferFullWait" -Value "40" -PropertyType "DWORD"
            New-ItemProperty -Path $path -Name "TCP Timeout" -Value "30000" -PropertyType "DWORD"
            New-ItemProperty -Path $path -Name "UDP Timeout" -Value "30000" -PropertyType "DWORD"
            New-ItemProperty -Path $path -Name "Connect Timeout" -Value "3000" -PropertyType "DWORD"
            New-ItemProperty -Path $path -Name "UDP Retry" -Value "3" -PropertyType "DWORD"
            New-ItemProperty -Path $path -Name "Search Timeout" -Value "5000" -PropertyType "DWORD"
            New-ItemProperty -Path $path -Name "BC Times" -Value "2" -PropertyType "DWORD"
            New-ItemProperty -Path $path -Name "PMType" -Value "1" -PropertyType "DWORD"
            New-ItemProperty -Path $path -Name "Driver" -Value "CNMN6PPM.DLL" -PropertyType "String"
            New-ItemProperty -Path $path -Name "FAXInstalled" -Value "0" -PropertyType "DWORD"
    
            #Specified Port Information
            $path = "$path\Ports"
            New-Item -Path $path -Name "CNBJNP_60128B8458CB"
            $path = "$path\CNBJNP_60128B8458CB"
            New-ItemProperty -Path $path -Name "TargetAddress" -Value "24291520" -PropertyType "DWORD"
            New-ItemProperty -Path $path -Name "TargetPort" -Value "8611" -PropertyType "DWORD"
            New-ItemProperty -Path $path -Name "TargetMAC" -Value "60-12-8B-84-58-CB" -PropertyType "STRING"
            Start-Sleep -s 5
            net stop "LPD Service"
            net stop "Spooler"
            Start-Sleep -s 5
            net start Spooler
            net start "LPD Service"
            Start-Sleep -s 5
    
            #registering Port
            rundll32 printui.dll,PrintUIEntry /if /q /m "Canon iP110 series" /f "C:\WINDOWS\INF\oem93.inf" /r "CNBJNP_60128B8458CB"
    
    }

    Attention: The script is for an SCCM installation,  there might be a problem with some configurations. And sorry that it's not a pictures, account needs to be verified -.-


    So, my question now is if there is a need for another link to that port or something? I cannot find any other setting which could do that. 

    Every help is appreciated! :)

    Thanks and greetings

    Fahiko



    • Edited by Fahiko Tuesday, June 6, 2017 2:24 PM
    Tuesday, June 6, 2017 11:54 AM

Answers

  • Hey all

    I finally did it.

    The problem was that the silent driver installation did NOT copy the files needed for the printer port type. So the registry was correct (all of the keys I added), but the reference on the driver file did not exist. It was specified in the registry (driver = CNMN6PPM.DLL), but this and the other files were not located in the C:\Windows\System32 folder, where all of the files are saved. 

    After copying the files to the System32 folder and restarting the spooler, everything worked like a charm! I'm now just super happy. 

    Your links all referenced on adding a port itself, but not on the port type or port monitor. I tried it with the registry (seen above), with the rundll32 PrintUI, with the Shell-Object "Install" and several other things. 

    Reference by https://docs.microsoft.com/en-us/windows-hardware/drivers/print/installing-a-print-monitor, https://serverfault.com/questions/566270/windows-command-for-adding-new-printer-port-type-using-inf-files and a bit from here http://www.techtalkz.com/microsoft-device-drivers/244983-installing-printer-port-monitor.html

    Thanks to all of your help. 

    Have a nice evening & weekend!

    Greetings

    Fahiko

    • Marked as answer by Fahiko Thursday, June 8, 2017 8:06 PM
    Thursday, June 8, 2017 8:06 PM

All replies

  • You will need to add printer ports using printer commands in either WMI or PS commands.

    Look in the Gallery for scripts that add printers and ports. There are many.


    \_(ツ)_/

    Tuesday, June 6, 2017 6:10 PM
  • Hey jrv Thanks for your answer. I already tried this way, but didn't find any way how to do this. In the Procmon File, I've nothing found like 'WMIxxx' or 'Add-xxx' for example in Powershell. The only thing I've found were the registry values shown in the script above and also the registering of the driver with the rundll32 PrintUI,UIEntry. But this is done by the silent installation of the setup.exe. And after the registering of the driver, a printer is added with the rundll32 PrintUI too, already specified by the port (which was not created by a command, neither by the setup itself). I am totally struggling at this point, but I'll try to do like you said. One question remains: What is with the printer port monitor (type)? This port type already contains a lot of settings, added by my registry values. So I've no idea how to do that when it isn't shown in the port type list. That's the main point of my question. As soon as I'm in the office (at thursday), I'll try it again, but I always appreciate any further tips or tricks. Or better said: How do I add a printer port with the port monitor as information? Thanks, Fahiko
    • Edited by Fahiko Tuesday, June 6, 2017 9:16 PM
    Tuesday, June 6, 2017 8:41 PM
  • help Add-PrinterPort -full

    help Add-pPinterDriver -full

    help Add-Printer -full

    Look at the examples carefully.

    Search for numerous blog posts that detail how to add printers.


    \_(ツ)_/

    Tuesday, June 6, 2017 9:19 PM
  • Hey all

    I finally did it.

    The problem was that the silent driver installation did NOT copy the files needed for the printer port type. So the registry was correct (all of the keys I added), but the reference on the driver file did not exist. It was specified in the registry (driver = CNMN6PPM.DLL), but this and the other files were not located in the C:\Windows\System32 folder, where all of the files are saved. 

    After copying the files to the System32 folder and restarting the spooler, everything worked like a charm! I'm now just super happy. 

    Your links all referenced on adding a port itself, but not on the port type or port monitor. I tried it with the registry (seen above), with the rundll32 PrintUI, with the Shell-Object "Install" and several other things. 

    Reference by https://docs.microsoft.com/en-us/windows-hardware/drivers/print/installing-a-print-monitor, https://serverfault.com/questions/566270/windows-command-for-adding-new-printer-port-type-using-inf-files and a bit from here http://www.techtalkz.com/microsoft-device-drivers/244983-installing-printer-port-monitor.html

    Thanks to all of your help. 

    Have a nice evening & weekend!

    Greetings

    Fahiko

    • Marked as answer by Fahiko Thursday, June 8, 2017 8:06 PM
    Thursday, June 8, 2017 8:06 PM
  • You always have to install the driver first.  Copying it to system does not really install the port driver but may allow some drivers to work.

    You should just use the provided CmdLets and scripts to install printers.


    \_(ツ)_/

    Thursday, June 8, 2017 9:45 PM
  • The driver was installled by using the "setup.exe /q" from the developer (Canon in this case). This one registers the driver, like "Add-Driver -Name 'Canon IP110 series' -Infpath 'C:\Company\Temp\Driver\config.inf'" does. That's exactly the same in this case. But the setup.exe didn't copy the files, so I had to copy them manually for the printer port monitor. 

    The IP110 is an exception, it's not like a normal printer installation ^^ For a normal printer, you were absolutely right. Thanks. 

    Friday, June 9, 2017 7:09 AM