CMD: Append to path without duplicating it?

Posted by Horst Walter on Super User See other posts from Super User or by Horst Walter
Published on 2012-09-27T10:23:15Z Indexed on 2012/09/27 15:40 UTC
Read the original article Hit count: 231

Filed under:
|
|

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:

  1. Related: How do I append user-defined environment variables to the system variable PATH in Windows 7?
  2. Related: How can I permanently append an entry into the system's PATH variable, via command line?
  3. Same question for UNIX: Add directory to $PATH if it's not already there

© Super User or respective owner

Related posts about Windows

Related posts about command-line