Hi Mark... welcome !

Before we start... you're code...

IF @ReturnCode = 0

did you mean to say this...

IF $ReturnCode = 0

Shawn.