From https://stackoverflow.com/questions/7005951/batch-file-find-if-substring-is-in-string-not-in-a-file, I figured how to check if PATH variable has a certain substring(groovy's path). However, my PATH variable has spaces in it and that results in error "Files\Amazon was unexpected at this time.".
set str1=%PATH%rem set str1=C:\lang\groovy-2.4.21\binrem set str1=fooif not x%str1:groovy-2.4.21=%==x%str1% goto noNeedToAddGroovyecho "Groovy is not in the path. Add groovy to the path"SET "PATH=C:\lang\groovy-2.4.21\bin;%PATH%;endlocal
In the above code block, the below line
if not x%str1:groovy-2.4.21=%==x%str1% goto noNeedToAddGroovy
gives the error "Files\Amazon was unexpected at this time".
How can I correctly escape the spaces in the str1 variable ?