When I open cmd.exe and type that first line and push ENTER, it works fine. When I input that other line and push ENTER, it closes immediately.
I can change (\'a\') to (
This guy seems to have solved a very similar problem successfully:
for /f closes cmd window immediately
The problem in that case turned out to have to do with the COMSPEC
environment variable, it being incorrectly set initially, as it seems. The guy applied logging out of the Windows account and back in.