Quotation marks around spaces aren't necessary in the PATH environment variable

Raymond Chen

The purpose of quotation marks is to allow a character that would normally be interpreted as a delimiter to be included as part of a file name. Most of the time, this delimiter is the space. The CreateProcess function uses a space to separate the program name from its arguments. Most programs separate their command line arguments with a space. But the PATH environment variable doesn’t use spaces to separate directories. It uses semicolons. This means that if you want to add a directory with spaces in its name to the path, you don’t need quotation marks since spaces mean nothing to the PATH environment variable. The quotation marks don’t hurt, mind you, but they don’t help either.

On the other hand, if the directory you want to add contains a semicolon in its name, then you do need the quotation marks, because it’s the semicolon that you need to protect.


Discussion is closed.

Feedback usabilla icon