After many hours I finally solved this problem.
The cause: for some reason system environmental variable has “ComSpec” set to string “path”, which is totally wrong.
It turns out ComSpec should point to the command line interpreter (see COMSPEC - Wikipedia). But “path” is not a valid path, so this messed with programs that issue commands through the command line interpreter.
After removing the environmental variable, everything returns normal.
I still don’t know how this ComSpec variable was created in the first place.