Implement more thorough shell command line escaping on Windows

See the first commit's message for a detailed description.