Difference between revisions of "Printer configuration"

From WPKG | Open Source Software Deployment and Distribution
Jump to: navigation, search
m
(Adding TCP/IP printer ports)
Line 1: Line 1:
WPKG can be used for configuring printers, too.
+
WPKG can be used for configuring printers and printer ports, too.
 +
 
 +
= Adding TCP/IP printer ports =
 +
 
 +
The following VBS script "addTcpipPort.vbs" adds a TCP/IP printer port, which can be then used by a printer installation:
 +
 
 +
<source lang="dos">
 +
Set args = WScript.Arguments
 +
printerPortName = args.Item(0)
 +
tcpipAddress    = args.Item(1)
 +
tcpipPortNumber = args.Item(2)
 +
Set objWMIService = GetObject("winmgmts:")
 +
Set objNewPort = objWMIService.Get _
 +
("Win32_TCPIPPrinterPort").SpawnInstance_
 +
objNewPort.Name = printerPortName
 +
objNewPort.Protocol = 1
 +
objNewPort.HostAddress = tcpipAddress
 +
objNewPort.PortNumber = tcpipPortNumber
 +
objNewPort.SNMPEnabled = False
 +
objNewPort.Put_
 +
</source>
 +
 
 +
Syntax:
 +
<source lang="dos">
 +
cscript addTcpipPort.vbs <new port name> <printer address> <printer port>
 +
</source>
 +
 
 +
Usage example, add a new printer port named "printerport1" with IP address "192.168.1.2" and port number "9100":
 +
<source lang="dos">
 +
cscript addTcpipPort.vbs printerport1 192.168.1.2 9100
 +
</source>
 +
 
 +
 
 +
 
 +
= Adding Printers =
  
 
When a new printer is configured on a server, it still has to be "installed" on a workstation.
 
When a new printer is configured on a server, it still has to be "installed" on a workstation.

Revision as of 14:49, 27 June 2008

WPKG can be used for configuring printers and printer ports, too.

Adding TCP/IP printer ports

The following VBS script "addTcpipPort.vbs" adds a TCP/IP printer port, which can be then used by a printer installation:

Set args = WScript.Arguments
printerPortName = args.Item(0)
tcpipAddress    = args.Item(1)
tcpipPortNumber = args.Item(2)
Set objWMIService = GetObject("winmgmts:")
Set objNewPort = objWMIService.Get _
("Win32_TCPIPPrinterPort").SpawnInstance_
objNewPort.Name = printerPortName
objNewPort.Protocol = 1
objNewPort.HostAddress = tcpipAddress
objNewPort.PortNumber = tcpipPortNumber
objNewPort.SNMPEnabled = False
objNewPort.Put_

Syntax:

cscript addTcpipPort.vbs <new port name> <printer address> <printer port>

Usage example, add a new printer port named "printerport1" with IP address "192.168.1.2" and port number "9100":

cscript addTcpipPort.vbs printerport1 192.168.1.2 9100


Adding Printers

When a new printer is configured on a server, it still has to be "installed" on a workstation.

A simple way to do it is the usage of startup scripts: executed with Administrator or SYSTEM rights - to install a printer on a workstation, and, user logon scripts, to install a printer for a user.

First, install a printer on a server and make sure it prints.

If it prints, add a line like this to /home/samba/unattended/packages/wpkg/wpkg-start.bat (the batch file where the WPKG is started):

 rundll32 printui.dll,PrintUIEntry /q /y /ga /in /n \\server\kyocera

with the appropriate servername and printername.

This has a drawback, that it'll be used by all machines.

To install a printer on certain workstations only, a WPKG entry like below could be used:

<package
  id="printer-kyocera"
  name="Kyocera printer"
  execute="always">

        <install cmd='rundll32 printui.dll,PrintUIEntry /q /y /ga /in /n \\server\kyocera' />

</package>

This ensures that it will be executed each time the workstation is booted.

Then, add the same line (rundll32 printui.dll,...) to user logon scripts.

After the machine is restarted, it should be able to use a new printer.