Answer from comments
From the MEL documentation, it states that "Every statement in MEL must end with a semi-colon (;)."
MEL strings also require quotations to be escaped, therefore double escape the internal quotations.
'maya.exe -command \"setProject \\\"'+dir+'\\\";\"'