Printer drivers

From WPKG | Open Source Software Deployment and Distribution
Jump to: navigation, search

Generic Instructions[edit]

Most printer drivers should come packaged with an INF file which describes them. Printui.dll provides a generic method to install these. You'll need to know the name of the printer driver, which you can obtain by examining the INF file. For check conditions, compare the version number against (on x86) HKLM\SYSTEM\CurrentControlSet\Control\Print\Environments\Windows NT x86\Drivers\Version-3\Your Printer Name Here\DriverVersion; on x64, look in the equivalent path under HKLM\SYSTEM\CurrentControlSet\Control\Print\Environments\Windows x64\[....]. You can obtain this information from the INF file or by examining a computer on which the driver is already installed.

For additional information on how to manipulate printers silently, run rundll32 PrintUI.dll,PrintUIEntry /?. Note that the string PrintUIEntry is case-sensitive.

(Note that if Point and Print is turned on and works correctly in your environment, none of this is probably necessary.)

Working Examples[edit]

HP Universal Printer Driver[edit]

<package
   id="hpuniv-drivers"
   name="HP Universal Printer Driver %PKG_DRIVERVERS%"
   revision="4-%PKG_DRIVERVERS%"
   reboot="false"
   priority="0">

   <variable name="PKG_DRIVERVERS" value="5.8.0.17508" />
   <variable name="PKG_INTERNALVERS" value="61.160.1.17508" />

   <variable name="PKG_SOURCE_PS" value="%SOFTWARE%\printerdrivers\hp-universal-v%PKG_DRIVERVERS%\PS-64\hpcu160v.inf" architecture="x64" />
   <variable name="PKG_SOURCE_PS" value="%SOFTWARE%\printerdrivers\hp-universal-v%PKG_DRIVERVERS%\PS-32\hpcu160d.inf" architecture="x86" />

   <variable name="PKG_SOURCE_PCL" value="%SOFTWARE%\printerdrivers\hp-universal-v%PKG_DRIVERVERS%\PCL6-64\hpcu160u.inf" architecture="x64" />
   <variable name="PKG_SOURCE_PCL" value="%SOFTWARE%\printerdrivers\hp-universal-v%PKG_DRIVERVERS%\PCL6-32\hpcu160c.inf" architecture="x86" />

   <check type="logical" condition="or">
     <check type="registry" condition="equals" path="HKLM\SYSTEM\CurrentControlSet\Control\Print\Environments\Windows NT x86\Drivers\Version-3\HP Universal Printing PS\DriverVersion" value="%PKG_INTERNALVERS%" />
     <check type="registry" condition="equals" path="HKLM\SYSTEM\CurrentControlSet\Control\Print\Environments\Windows x64\Drivers\Version-3\HP Universal Printing PS\DriverVersion" value="%PKG_INTERNALVERS%" />
   </check>

   <check type="logical" condition="or">
     <check type="registry" condition="equals" path="HKLM\SYSTEM\CurrentControlSet\Control\Print\Environments\Windows NT x86\Drivers\Version-3\HP Universal Printing PCL 6\DriverVersion" value="%PKG_INTERNALVERS%" />
     <check type="registry" condition="equals" path="HKLM\SYSTEM\CurrentControlSet\Control\Print\Environments\Windows x64\Drivers\Version-3\HP Universal Printing PCL 6\DriverVersion" value="%PKG_INTERNALVERS%" />
   </check>

   <!-- unfortunately /h doesn't seem to work to install
        drivers for both architectures on one computer (tested on XP and 7), so
        we do this instead.  It would probably be possible to ignore return
        codes instead.  -->
   <install cmd='rundll32 PrintUI.dll,PrintUIEntry /ia /f "%PKG_SOURCE_PS%" /m "HP Universal Printing PS" /q' />
   <install cmd='rundll32 PrintUI.dll,PrintUIEntry /ia /f "%PKG_SOURCE_PCL%" /m "HP Universal Printing PCL 6" /q' />

   <upgrade include="install" />
   <remove cmd='rundll32 PrintUI.dll,PrintUIEntry /dd /m "HP Universal Printing PS" /q' />
   <remove cmd='rundll32 PrintUI.dll,PrintUIEntry /dd /m "HP Universal Printing PCL 6" /q' />

</package>

Ricoh universal driver (PS)[edit]

<package
   id="ricoh-univ-drivers"
   name="Ricoh drivers, universal PS"
   revision="%PKG_DRIVERVERS%"
   reboot="false"
   priority="0">

   <variable name="PKG_DRIVERVERS" value="4.3.0.0" />
   <variable name="PKG_SOURCE" value="%SOFTWARE%\printerdrivers\ricoh-universal-ps-%PKG_DRIVERVERS%\64bit\disk1\RICSETUP64.INF" architecture="x64" />
   <variable name="PKG_SOURCE" value="%SOFTWARE%\printerdrivers\ricoh-universal-ps-%PKG_DRIVERVERS%\32bit\disk1\RICSETUP.INF" architecture="x86" />

   <check type="logical" condition="or">
     <check type="registry" condition="equals" path="HKLM\SYSTEM\CurrentControlSet\Control\Print\Environments\Windows NT x86\Drivers\Version-3\PS Driver for Universal Print\DriverVersion" value="%PKG_DRIVERVERS%" />
     <check type="registry" condition="equals" path="HKLM\SYSTEM\CurrentControlSet\Control\Print\Environments\Windows x64\Drivers\Version-3\PS Driver for Universal Print\DriverVersion" value="%PKG_DRIVERVERS%" />
   </check>

   <install cmd='rundll32 PrintUI.dll,PrintUIEntry /ia /f "%PKG_SOURCE%" /m "PS Driver for Universal Print" /q' />

   <upgrade cmd='rundll32 PrintUI.dll,PrintUIEntry /ia /f "%PKG_SOURCE%" /m "PS Driver for Universal Print" /q' />
   <remove cmd='rundll32 PrintUI.dll,PrintUIEntry /dd /m "PS Driver for Universal Print" /q' />

</package>

HP Deskjet 5800 series[edit]

<package
   id="hpdj5800-drivers"
   name="HP Deskjet 5800 series"
   revision="1"
   reboot="false"
   priority="0">

   <!-- XXX this check is inadequate. Wpkg doesn't handle REG_BINARY very well. -->
   <!-- Note: the packages only provide x86 drivers, so no other arch are checked -->

   <check type="registry" condition="equals" path="HKLM\SYSTEM\CurrentControlSet\Control\Print\Environments\Windows NT x86\Drivers\Version-3\hp deskjet 5800 series\Data File" value="hpf4h409.dat" />

   <install cmd='rundll32 PrintUI.dll,PrintUIEntry /ia /f "%SOFTWARE%\printerdrivers\lj5800-basic\5800\enu\drivers\win2k_xp\hpf5800k.inf" /m "hp deskjet 5800 series" /q' />

</package>

Samsung SCX-4x28 Series (Requires WPKG 1.2.1-RC20 or higher)[edit]

Tested only on Windows 7

Script to install drivers and network printer (IP-port connection)

<packages>
        <package
                id="printer-samsung"
                name="Printer Samsung"
                revision="20120117-04"
                priority="0"
                reboot="false">

                <variable name="PKG_PRINTERNAME"    value="Samsung SCX-4x28 Series PS" />
                <variable name="PKG_ADDRESS"        value="192.168.1.11" />
                <variable name="PKG_PRINTERMODEL"   value="Samsung SCX-4x28 Series PS" />
                <variable name="PKG_LANGUAGEFULL"   value="English"/>
                <variable name="PKG_LANGUAGEFULL"   value="Russian" lcid="419,1049,422,1058"/>
                <variable name="PKG_SOURCE"         value="%SOFTWARE%\hardware\Samsung SCX-4828FN\Printer\PS\%PKG_LANGUAGEFULL%\WinXP_VISTA_64\smf428.inf"       architecture="x64" />
                <variable name="PKG_SOURCE"         value="%SOFTWARE%\hardware\Samsung SCX-4828FN\Printer\PS\%PKG_LANGUAGEFULL%\WinXP_2000_VISTA_32\smf428.inf"  architecture="x86" />
                <variable name="PKG_DRIVERSDATA"    value="smf428.ppd" />

                <variable name="PKG_LANGUAGE"       value="en-US"/>
                <variable name="PKG_LANGUAGE"       value="ru-RU"   lcid="419,1049,422,1058"/>
                <variable name="PKG_PRNPORT"        value="%windir%\System32\prnport.vbs" os="5\.\d\.\d{4}" /> <!-- WinXP/2000 -->
                <variable name="PKG_PRNPORT"        value="%windir%\System32\Printing_Admin_Scripts\%PKG_LANGUAGE%\prnport.vbs" os="6\.\d\.\d{4}" /> <!-- Vista/Seven -->

                <check type="logical" condition="or">
                        <!-- Windows XP -->
                        <check type="registry" condition="equals" path="HKLM\SYSTEM\CurrentControlSet\Control\PrintEnvironments\Windows NT x86\Drivers\Version-3\%PKG_PRINTERMODEL%\Data File"  value="%PKG_DRIVERSDATA%" />
                        <check type="registry" condition="equals" path="HKLM\SYSTEM\CurrentControlSet\Control\PrintEnvironments\Windows x64\Drivers\Version-3\%PKG_PRINTERMODEL%\Data File"     value="%PKG_DRIVERSDATA%" />
                        <!-- Windows 7 -->
                        <check type="registry" condition="equals" path="HKLM\SYSTEM\CurrentControlSet\Control\Print\Environments\Windows NT x86\Drivers\Version-3\%PKG_PRINTERMODEL%\Data File" value="%PKG_DRIVERSDATA%" />
                        <check type="registry" condition="equals" path="HKLM\SYSTEM\CurrentControlSet\Control\Print\Environments\Windows x64\Drivers\Version-3\%PKG_PRINTERMODEL%\Data File"    value="%PKG_DRIVERSDATA%" />
                </check>

                <!-- -s %PKG_SERVER% -->
                <install cmd='cscript.exe "%PKG_PRNPORT%" -a -r IP_%PKG_ADDRESS% -h %PKG_ADDRESS% -me -y public -i 1 -o raw -n 9100' />
                <install cmd='rundll32 PrintUI.dll,PrintUIEntry /if /b "%PKG_PRINTERNAME%" /f "%PKG_SOURCE%" /m "%PKG_PRINTERMODEL%" /r "IP_%PKG_ADDRESS%"' />
                <install cmd="net stop spooler" />
                <install cmd="net start spooler" />

                <upgrade include="remove" />
                <upgrade include="install" />

                <remove timeout="15" cmd='rundll32 PrintUI.dll,PrintUIEntry /dl /n "%PKG_PRINTERNAME%"' >
                        <exit code="any" />
                </remove>
                <remove timeout="15" cmd='cscript.exe "%PKG_PRNPORT%" -d -r IP_%PKG_ADDRESS%' >
                        <exit code="any" />
                </remove>
                <remove timeout="15" cmd='rundll32 PrintUI.dll,PrintUIEntry /dd /m "%PKG_PRINTERMODEL%"' >
                        <exit code="any" />
                </remove>
                <remove cmd="net stop spooler" />
                <remove cmd="net start spooler" />
        </package>
</packages>


Samsung ML-2570 Series (Requires WPKG 1.2.1-RC20 or higher)[edit]

Tested with Windows XP only.

It is script to install drivers and network printer (IP-port connection) without printui.dll (It may be helpful if printer setup not work under domain user in Windows XP)

<packages>

<package
   id="samsung_net_prn"
   name="Network printer setup"
   revision="1"
   
   reboot="false"
   priority="10">
 
   <variable name="port" value="192.168.1.11" />
   <variable name="name"    value="Network printer" />
    <variable name="model"   value="Samsung ML-2570 Series PCL 6" />
 
   <check type="registry" condition="exists" path="HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Print\Printers\%name%\" />
   <install cmd='cscript %WINDIR%\system32\prnport.vbs -a -r IP_%port% -h %port% -o raw -n 9100' />
   <install cmd='cscript %WINDIR%\system32\prndrvr.vbs -a -m "%model%" -v 3 -e "Windows NT x86" -i \\server\wpkg\installers\printers\samsung_ml-2570\WinXP2K\ml2570.inf' />
   <install cmd='cscript %WINDIR%\system32\prnmngr.vbs -a -p "%name%" -m "%model%" -r IP_%port%' />
   <remove cmd='cscript %WINDIR%\system32\prnmngr.vbs -d -p "%name%"' />
   <remove cmd='cscript %WINDIR%\system32\prnport.vbs -d -r IP_%port%' />
</package>

</packages>


DELL 2155cn[edit]

<package
	id='printer_dell2155' 
	name='DELL-MFP' 
	revision="%version%"
	priority='0' 
	reboot='false'>
		
	<variable name="version" value="1"/>
	<variable name="port" value="192.168.1.111" />
	<variable name="PrinterName" value="DELL-MFP" />
	<variable name="model" value="Dell 2155cn Color MFP PCL6" />
		
	<check type="registry" condition="exists" path="HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Print\Printers\%PrinterName%" />
		
	<install cmd='cscript %SYSTEMROOT%\system32\prnport.vbs -a -r IP_%port% -h %port% -o lpr -q lp' />
	<install cmd='cscript %SYSTEMROOT%\system32\prndrvr.vbs -a -m "%model%" -v 3 -e "Windows NT x86" -i %SOFTWARE%\Dell2155\dlxgizi.inf' />
	<install cmd='cscript %SYSTEMROOT%\system32\prnmngr.vbs -a -p "%PrinterName%" -m "%model%" -r IP_%port%' />
		
	<remove cmd='cscript %SYSTEMROOT%\system32\prnmngr.vbs -d -p "%PrinterName%"' />
	<remove cmd='cscript %SYSTEMROOT%\system32\prnport.vbs -d -r IP_%port%' />
</package>

==

Adding a Printer Port[edit]

If you need to add a Printer using an IP Port you have to create the Port first. I did it under WinXP with the build in prnport.vbs. Create a Batch file and run this, to install a Brother HL-2150N connected to the Port ExamplePortName behind the IP ExampleIP (RAW Mode Port 9100).

cscript %WINDIR%\system32\prnport.vbs -a -r ExamplePortName -h ExampleIP -o raw -n 9100
rundll32 PrintUI.dll,PrintUIEntry /if /b "Brother HL-2150N" /f "%SOFTWARE%\BrotherHL2150N\BROHL07A.INF" /m "Brother HL-2150N series" /r "ExamplePortName"

For Windows Seven there is another path for prnport.vbs:

...
cscript %WINDIR%\System32\Printing_Admin_Scripts\%PKG_LANGUAGE%\prnport.vbs -a -r ExamplePortName -h ExampleIP -o raw -n 9100
...