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 ('asdfgh') then same problem. or %q to %f same problem.
The difference is the /f, for some reason the FOR /F with ('......') causes cmd.exe to close.
This happens on one of my systems and not another
C:\>for %q in ('a') do echo %q <ENTER>
C:\>echo 'a'
'a'
C:\>for /f %q in ('a') do echo %q <ENTER>
a
being a wrong command. – Andriy M