12
3
For one CMD
session I can easily set a new path: SET PATH=%PATH%;"insert custom path here"
Doing so in a batch file does not consider whether the custom path is already included. How do I avoid duplicating it (i.e. check whether it is already contained in the PATH "string").
Remarks:
- Related: How do I append user-defined environment variables to the system variable PATH in Windows 7?
- Related: How can I permanently append an entry into the system's PATH variable, via command line?
- Same question for UNIX: Add directory to $PATH if it's not already there
- Some "CMD" String ops explained: http://ss64.com/nt/syntax-replace.html
It should be pointed out that in this context, the duplication is harmless. It would probably be more sensible to allow the duplication to occur than to try to avoid it and introduce the risk of a false positive. – Harry Johnston – 2012-09-27T22:58:35.013