Gary,
I dont know whether this fits the bill, but this is what we use in our logon scripts to search and destroy existing printers, (we then re-add them based upon group memberships)$KEY = "HKEY_CURRENT_USER\Printers\Connections"
$DEL_PRT_ERR_CNT = 0
$SubKey = EnumKey( $KEY , 0 )
WHILE @ERROR = 0 AND $DEL_PRT_ERR_CNT = 0
$wrk = SUBSTR($Subkey,3,30)
$comma = instr($wrk,",")
$svrend = $comma - 1
$prtsrt = $comma + 1
$svr = RTRIM(SUBSTR($wrk,1,$svrend))
$prt = RTRIM(SUBSTR($wrk,$prtsrt,20))
$uncname = "\\"+$svr+"\"+$prt
? "unc name is >>"+$uncname+"<<"
$DEL_RC = delprinterconnection($uncname)
If $DEL_RC <> 0
$DEL_PRT_ERR_CNT = $DEL_PRT_ERR_CNT + 1
endif
? "return code from delpc is "+$DEL_RC+" error text is "+@SERROR+"."
$SubKey = EnumKey( $KEY , 0)
LOOP
I have hacked this out of a larger script, but I cant see any uninitialised variables etc (but I have been wrong before).
I hope this helps.
PS: the rest of my script then checks on group memberships and add printers - but this add is done by checing a short list of servers for the presence of a printer share - this bit of code might be useful to you aswell I guess - if it is say - Ill append it.
Mark