We have a bunch of IP based printers that we need to install.  Unfortunately, we have no print server to pull the drivers from and install the printers.  I have the following script tha works great for installing printers...

regedit /s file.reg

net stop "print spooler"
net start "print spooler"

RUNDLL32 PRINTUI.DLL,PrintUIEntry /if /b "Printer Name" /f "\\location to INF" /r "IP_100.00.000.000" /m "RICOH Aficio MP C2050 PCL 6"

rundll32 printui.dll,PrintUIEntry /y /q /n “Printer Name”

The problem I am having is that we need to change the printer preferences (paper size, type, ect...) after the printers are install on the client.  Is there anyway to script these changes or does anyone know any other options?


EDIT:  or is there a script to change the port afteR?

Answer Summary:
0 Comments   [ - ] Hide Comments


Please log in to comment

Answer this question or Comment on this question for clarity



This info is stored in the registry. Install the printer with the settings you want to migrate then export the following keys. Import them in this order or you may experience some problems:



1.Driver registry data


[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Environments\Windows NT x86\Drivers\Version‐3\DRIVERNAME]


2.Port registry data


[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports]


3.Printer registry data




[HKEY_LOCAL_MACHINE\SOFTWARE\Microso^\Windows NT\CurrentVersion\Print\Printers]


4.Printer Settings registry data




Answered 02/08/2013 by: mpace
Red Belt

  • Thanks, but I actually found a way to do what is needed. We are going to setup the printers on a system first, change settings, and then export those settings to a DAT file.

    Then we are going to setup the IP printer via SCCM/script and import the DAT file with all the specific printer settings.

    Would be much easier and less of a pain if they would just go back to using a print server.
  • Question : How did you get past the 0x0000003 error that always popup when trying this command ?
    • We actually had issues using the DAT file to import the settings. As it turned out, the printer itself told the PC what the settings were and made adjustments so we didnt have to go that route. Look here at the script I am using to install printers....

      cscript prnport.vbs -a -r IP_000.000.000.000 -h >nul 2>nul

      RUNDLL32 PRINTUI.DLL,PrintUIEntry /if /b "Printer Name" /f "path\to\drivers" /r "IP_000.000.000.000" /m "Printer name as listed in the driver INF file"

      rundll32 printui.dll,PrintUIEntry /y /q /n "Printer Name"
      • I'm already creating the port in the registry keys but when I use this command, nothing works.

        Code :

        :: InstImprimante.cmd
        :: Script d'installation d'une imprimante reseau
        :: (L) 2010 Badministrateur.com
        rem @echo off

        :: Remplacer les 3 champs suivants par vos valeurs
        :: ATTENTION: Le nom de l'imprimante doit correspondre au nom de vortre imprimante dans le fichier INF (cf section [DriverName.xxxxx])
        :: Le nom de la file d'attente LPR peut etre trouvé en installant l'imprimante manuellement et en verifiant les propriétés du port TCP/IP d'une installation "témoin"
        :: Mettre un chemin absolu pour le pilote d'impression

        set AdresseIP=
        set Imprimante=HP LaserJet 4050 Series PCL 6
        set Pilote=v:\Partage\echange\pcl6\hpbf002i.inf

        :: --- Ne pas toucher Â… la suite du fichier ---
        echo Creation d'un port d'impression TCP/IP a l'adresse %AdresseIP%
        set CLEPORT="HKLM\System\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports"
        REG ADD %CLEPORT%\IP_%AdresseIP% /f > NUL
        REG ADD %CLEPORT%\IP_%AdresseIP% /v Protocol /t REG_DWORD /d 0x00000002 /f > NUL
        REG ADD %CLEPORT%\IP_%AdresseIP% /v Version /t REG_DWORD /d 0x00000001 /f > NUL
        REG ADD %CLEPORT%\IP_%AdresseIP% /v HostName /t REG_SZ /d "" /f > NUL
        REG ADD %CLEPORT%\IP_%AdresseIP% /v IPAddress /t REG_SZ /d %AdresseIP% /f > NUL
        REG ADD %CLEPORT%\IP_%AdresseIP% /v PortMonMibPortIndex /t REG_DWORD /d 0x00000001 /f > NUL
        REG ADD %CLEPORT%\IP_%AdresseIP% /v HWAddress /t REG_SZ /d "" /f > NUL
        REG ADD %CLEPORT%\IP_%AdresseIP% /v PortNumber /t REG_DWORD /d 0x00000203 /f > NUL
        REG ADD %CLEPORT%\IP_%AdresseIP% /v "SNMP Community" /t REG_SZ /d Public /f > NUL
        REG ADD %CLEPORT%\IP_%AdresseIP% /v "SNMP Enabled" /t REG_DWORD /d 0x00000000 /f > NUL
        REG ADD %CLEPORT%\IP_%AdresseIP% /v "SNMP Index" /t REG_DWORD /d 0x00000001 /f > NUL

        :: Redemarrage du spooler d'impression
        net stop spooler
        net start spooler

        :: Installation de l'imprimante
        echo Installation de l'imprimante %Imprimante% sur le port TCP_%AdresseIP%. Veuillez patienter...
        rundll32 printui.dll,PrintUIEntry /if /f "%Pilote%" /b "%Imprimante%" /r IP_%AdresseIP% /m "%Imprimante%"

        :: Mettre l'imprimante par defaut
        rundll32 printui.dll,PrintUIEntry /y /n "%Imprimante%"
    • For most of my printers, Canons, I use the VBS method of creating the port. Like I posted before, here is a sample script.

      cscript prnport.vbs -a -r IP_000.000.000.000 -h >nul 2>nul

      RUNDLL32 PRINTUI.DLL,PrintUIEntry /if /b "Printer Name" /f "path\to\drivers\inffilename.inf" /r "IP_000.000.000.000" /m "Printer name as listed in the driver INF file"

      rundll32 printui.dll,PrintUIEntry /y /q /n "Printer Name"

      Other printers, HPs, the VBS method of creating the port does not work so I have to import using a registry file. Here is a sample...

      regedit /s NameOfRegFile.reg >nul 2>nul

      net stop "print spooler" >nul 2>nul
      net start "print spooler" >nul 2>nul

      RUNDLL32 PRINTUI.DLL,PrintUIEntry /if /b "Printer Name" /f "Path\Driver\Inf\inffilename.inf" /r "IP_000.000.000.000" /m "Name of printer in INF"

      rundll32 printui.dll,PrintUIEntry /y /q /n "Printer Name"

      Here is a sample Registry file that I use...

      Windows Registry Editor Version 5.00

      [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\IP_000.000.000.000]
      "SNMP Community"="public"
      "SNMP Enabled"=dword:00000000
      "SNMP Index"=dword:00000001

      Also, make sure you are running this as admin or giving people permission to edit the following registry key and all sub keys...

      If users cannot edit the above reg key, then this will not work because the script cannot create the port. I gave permission to all systems via group policy.
      • When I try you prnport.vbs synthax, I always get an error that the file is used by another process. Do you have any clue ?

        EDIT : Sorry... I was using >null instead of >nul LOL !

        EDIT #2 : And I managed to make it work but not with prnport.vbs but with the registry key import method. Thank you ! I will now be able to make my SCCM task sequence to install the printer in the school lab I need to have it. I have 4 printers I need to install this way because they are not compatible (too old) with our print server.
  • This content is currently hidden from public view.
    Reason: Removed by member request
    For more information, visit our FAQ's.
  • wrong post
Please log in to comment
Admin Script Editor
Admin Script Editor is an integrated scripting environment available free here at ITNinja