Thursday, February 22, 2007

Automatically install networkprinters on a Windows server

Another day, another blog entry!

Say: you want to install all the network printers on a Windows server to a workstation. One very easy way to do this is to use KiXtart. This is a very powerful scripting tool which you can run on Windows.

Install kix32.exe in the netlogon folder and run kix32.exe printers.kix from your login script.

You need to change the following script to the printers you want to use and save the script as printers.kix into the netlogon folder:

Dim $printers[10]
$printers = "\\SERVER01\Printer 1","\\SERVER01\Printer 2","\\SERVER01\Printer 3"

$X = KeyExist("HKEY_CURRENT_USER\Software\Terminator")
If not $X
$X = AddKey("HKEY_CURRENT_USER\Software\Terminator")

$Y = ReadValue("HKEY_CURRENT_USER\Software\Terminator", "1")
If not @ERROR = 0
while $loop > 1
DelPrinterConnections ()
$loop=$loop - 1
$Y = WriteValue("HKEY_CURRENT_USER\Software\Terminator", "1", "1", "REG_SZ")
If @ERROR = 0

For Each $Element In $printers
if AddPrinterConnection ("$Element") = 0
? $Element " was installed!"

function DelPrinterConnections()
dim $c,$bk,$conn
while @error=0
? "Networkprinter removed..."

This script will remove all old networkprinters an install \\SERVER01\Printer 1, \\SERVER01\Printer 2 and \\SERVER01\Printer 3. It will also change a value in the registry so this script will not change anything until you want it to. This way, if a user has selected a default printer it will not be changed on every logon.

Also you could expand the script to install specific printers for specific users, workstations or even IP adress ranges.

No comments: