How to append to Path if not already appended

batch-file, environment-variables, windows

Solution

Here's another solution:

path|find /i "%MYSQL_HOME%\bin"    >nul || set path=%path%;%MYSQL_HOME%\bin
path|find /i "%CATALINA_HOME%\bin" >nul || set path=%path%;%CATALINA_HOME%\bin

Problem

I want to append `%MYSQL_HOME%\bin` and `%CATALINA_HOME%\bin` to the `Path` system environment variable on Windows, but I want to append these only if they are not already appended. How do I do it on the command prompt or in a batch script?

Original source

Related problems