You can display error codes with this line
code:
? 'Error '+@ERROR+' - '+@SERROR

Secondly, ADDPRINTERCONNECTION requires the share name of the printer whereeas SETDEFAULTPRINTER requires the printer name, they might not be the same.

Finally, if the user cannot install printer drivers, the ADDPRINTERCONNECTION might fail, too.
_________________________
There are two types of vessels, submarines and targets.