So so so close. I really like this solution much better Kent, because it doesn't rely on COM stuff at all.
I just tested it (and added a few +'s you were missing). Here's my code:
Code:
cls
break on
? "Checking Stuff"
; -- USING IDEAS FROM - http://www.kixtart.org/ubbthreads/showflat.php?Cat=&Number=81569
; -- "Default Printer Configuration"
$reg='HKCU\Software\Microsoft\Windows NT\CurrentVersion'
$dev=$reg+'\Devices'
$nprt=split(READVALUE($reg+'\Windows','Device'),',')[0]
$NEW='HSCXNTFP0101'
$OLD='TYPHOON'
; -- CHECK FOR AND SET THE DEFAULT PRINTER
If $nprt<>''
$srv=SPLIT($nprt,'\')[2] ; SERVER
IF $srv=$old
$prn=SPLIT($nprt,'\')[3] ; PRINTER
$rc=ADDPRINTERCONNECTION('\\'+$new+'\'+$prn)
$rc=DELPRINTERCONNECTION('\\'+$srv+'\'+$prn)
$rc=SETDEFAULTPRINTER('\\'+$new+'\'+$prn)
ENDIF
ENDIF
; -- NOW ENUMERATE INSTALLED PRINTERS AND MOVE
$i=0
DO
IF '\\'=LEFT($x,2)
$srv=SPLIT($x,'\')[2]
IF $srv=$old
$prn=SPLIT($x,'\')[3]
$rc=ADDPRINTERCONNECTION('\\'+$srv+'\'+$prn)
$rc=DELPRINTERCONNECTION('\\'+$srv+'\'+$prn)
ENDIF
ENDIF
$x=ENUMVALUE($dev,$i)
$i=$i+1
UNTIL @error
? "Done"
EXIT
The problem is that if I setup 2 printers on the old server. 1 as default, the other not. Only the default one gets moved (though it IS reassigned as default, which is great!). The other simply gets deleted.
I was going to step through your code, but I figured you knew it better than I did. I don't mind debugging it if you're too busy though ;-)