I think you may be over thinking this, as you already know what you want .. see if this will help you get in the right direction: (untested code)

Code:
 

break on

$default=GetDefaultPrinter()
? $default
$=DELPRINTERCONNECTION ($default)
? @serror
$=addprinterconnection($default)
? @serror
$=SETDEFAULTPRINTER($default)
? @serror

function GetDefaultPrinter()
$GetDefaultPrinter = join(split(readvalue("HKEY_USERS\"+@sid+"\Software\Microsoft\Windows NT\CurrentVersion\Windows","Device"),',',1),'')
endfunction