you can also wonder why this'd fail :

$Reg = $VERYLONGVARIABLESIMPLYUNDEFINED + '\SOMEKEY'

Think its time to think over providing registry related code that is as posted simply incomplete (at least in starters section) [Wink]
_________________________