replaces connection from printer1 to printer2
preserves default printer


Code:

$oldprinter='\\server\Printer share1'
$newprinter='\\server\Printer share2'

ReplacePrinter($oldprinter, $newprinter)


function ReplacePrinter($oldprinter, $newprinter)

for each $Item in split(WMIQuery('Name','Win32_Printer'),'|')
if $item = $oldprinter
$=addprinterconnection($newprinter)
If not @error
$GetDefaultPrinter = join(split(readvalue("HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows","Device"),',',1),'')
if $GetDefaultPrinter = $oldprinter
$=setdefaultprinter($newprinter)
endif
$=delprinterconnection($oldprinter)
endif
endif
next

Endfunction




It currently used WMIQuery, but I'll eventually change it so it doesn't have that dependancy
_________________________
How to ask questions the smart way <-----------> Before you ask