Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I noticed that the semicolon ; is a valid character for Windows (NTFS) file and directory names.

The semicolon is, however, used as element delimiter for the PATH environment variable.

Say I have a folder called C:\"main() {printf('%d', 42);}" (heh, nice, also contains a percent sign) -- how could I add this folder to the system PATH?

share|improve this question
Avoid using semicolons in folder names, then you won't have a problem! – Lee Taylor Apr 19 '13 at 10:08
Well, you should be in control of folders that you're adding to PATH. It seems odd that you'd have folders with semicolons, etc. in them. – Lee Taylor Apr 19 '13 at 10:22
As has been said, you really should avoid using such characters in paths--They will trip up many unsuspecting programs which you do not have to source code to rewrite to handle them. What I would suggest, if you must have this kind of path for a specific program, write a batch file that sets the path needed by this one program, executes that one program, then restores the path to normal when done. Then you can put that batch file on the path somewhere to call when you need to run that program, without clobbering the path for all other programs. – C. M. Jul 19 '14 at 23:46

Using double quotes works for me:

SET PATH=%PATH%;"C:\main() {printf('%d', 42);}"
share|improve this answer

Get the folder short name via DIR /X, then add that short name to the PATH. It seems that PATH is OK with % sign though

share|improve this answer
Bah. Short-Names. But, yes, indeed, this appears to be a possible solution iff one is able to determine the short name. – Martin Apr 19 '13 at 10:06
So you mean how would you add if the user disabled the short name generation? – Martheen Cahya Paulo Apr 19 '13 at 10:17
Either by creating a junction point or symbolic link with simple name and adding it to the PATH then. – Martheen Cahya Paulo Apr 19 '13 at 10:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .