title: Remove unwanted path name from %path% variable via batch
body: <p>Scope:  Windows XP or newer
  Tools:  Batch script</p>
  
  <p>I need to be able to remove an unneeded path name from the system %PATH% variable. I know how to add a new path name to the system %PATH% variable, using a tool such as SETX.EXE, which also makes it immediately available within the existing CMD environment. It's probably a matter of using FIND and/or a FOR loop of some kind, but I'm not quite sure how to accomplish this. Here's a sample path statement...</p>
  
  <pre><code>%PATH% = C:\;C:\Program Files\Common Files\Java;C:\oracle\product\10.2.0\bin;C:\WINDOWS;C:\WINDOWS\system32;
  </code></pre>
  
  <p>From this, I need to be able to remove the full path name related to "oracle." So, in the above example, I need to be able to remove the "C:\oracle\product\10.2.0\bin" from the above path statement. Unfortunately, not only could the oracle path name be different than shown above, there could be multiple oracle path names and all need to be removed. I tried implementing the solution here...</p>
  
  <blockquote>
    <p><a href="https://stackoverflow.com/questions/670224/how-can-i-extract-a-full-path-from-the-path-environment-variable">How can I extract a full path from the PATH environment variable?</a></p>
  </blockquote>
  
  <p>However, it just isn't working. The script wouldn't find the path name. Any help would be appreciated. Thank you.</p>