I am sure there are many ways to do this... here is one.

I wrote a UDF called PrinterList() which has an option to display the port the printer is running on. So the code could look something like the following (untested):
Code:


$printers=printerlist(,1)
$localprinter=0
$counter=0
while $localprinter=0 and $counter<=ubound($printers)
if left(split($printers[$counter],",")[1],3)="LPT"
$localprinter=1
$=setdefaultprinter(split($printers[$counter],",")[0])
endif
$counter=$counter+1
loop
if $localprinter=0
$=addprinterconnection("\\server\printer")
$=setdefaultprinter("\\server\printer")
endif




This could be all wrapped up in its own UDF but I'll leave that for you or someone else.


Edited by Al_Po (2004-08-05 11:46 PM)