Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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 at 23:46

2 Answers 2

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
1  
So you mean how would you add if the user disabled the short name generation? support.microsoft.com/kb/121007 –  Martheen Cahya Paulo Apr 19 '13 at 10:17
1  
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

Using double quotes works for me:

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.