I guess execute will always work and reset the error to 0.

your use command UNC is not encapsulated...

change your execute to:
 Code:
$ = execute($command + " " + $ERROR = @error)


to be whitespace safe, change your use line to:
 Code:
tryCommand("use 'e:' '\\fileserver\share1'")
_________________________
!

download KiXnet