Searching Windows PATH envoironment variable for file

(imported topic written by jeko1791)

Hi,

I’m trying to search for a file that could exist in any of the folders under the PATH environment variable. I have come up with the following relevance clauses to:

search several folders for the file:

q: exists file “devcon.exe” of folders (“C:\Program Files\Support Tools”;“C:\Program Files\Windows Resource Kits\Tools”)

A: True

and to list all the folders under the PATH environment variable, encapsulated in quotes and separated by semi-colons:

q: ("%22" & (concatenation “%22;%22” of (substrings separated by “;” of value of variable “PATH” of environment)) & “%22”) as string

A: “C:\Program Files\Support Tools”;“C:\Program Files\Windows Resource Kits\Tools”;“C:\WINDOWS\system32”;“C:\WINDOWS”;“C:\WINDOWS\System32\Wbem”;“C:\Program Files\Common Files\Crystal Decisions\2.5\bin”

but when I combine these two clauses to search all of the folders of the PATH variable, I don’t get the expected TRUE result:

q: exists file “devcon.exe” of folders (("%22" & (concatenation “%22;%22” of (substrings separated by “;” of value of variable “PATH” of environment)) & “%22”) as string)

A: False

What am I doing wrong here, and how can I search these multiple folders from the PATH variable?

(imported comment written by SystemAdmin)

While I am sure there is a way to get that working, searching for files in folders is “expensive” in terms of how much time the agent has to put into it. Since the file is only 78k, it might be easier to just download it to the system folder and after that check for its existence there. That way you know where it is and you know it will be in the PATH statement. Just a suggestion…keeps it nice and simple.

(imported comment written by NoahSalzman)

The problem is that when you concatenate you get a

singular string

instead of

plural substrings

or

plural strings

. The

folders

operator can’t figure out that the singular string contains a collection of multiple folder paths.

Try:

exists file "devcon.exe" of folders (substrings separated by ";" of value of variable "PATH" of environment)

(imported comment written by jeko1791)

Excellent noah,

Thanks.

I guess the substrings don’t need to be in quotes, as I was trying to accomplish with the concatenate command and “%22”?

(imported comment written by NoahSalzman)

Yes, the

folders

operator is able to work with the substrings without extra quotes being added. What you were doing made sense, but ended up being more than was needed.