A couple of things...

The access denied may be coming from something else. Your command prompt box shows Windows Script Host, which I believe is a vbscript.

Your Select\Case is missing the Endselect

Place
? @result + " - " + @serror
under each use statement as a test to see what your results really are.