Relevance of checking existence of file, folder, and version info

(imported topic written by SystemAdmin)

I wanted to see if I could get some help on how to tackle this. I’ve tried several different ways but just can’t quite seem to get it right.

What I need to do is check for the existence of the file “subinacl.exe” in the ((value of variable “ProgramFiles” of environment) & “\Windows Resource Kits\Tools”) folder and check the version of it. I want the relevance to evaluate as TRUE if either the file doesn’t exist at all or if the file version is not “5.2.3790.1180.” What’s killing me is trying to get the relevance to run without generating the error “Singular expression refers to nonexistent object” if any part of the directory path is not there since if the directory doesn’t exist then it can’t check the version of the file (or at least the way I was trying to write it).

So - how do I accomplish this and prevent errors in case of non-existent folders or files?

(imported comment written by BenKus)

Hey d8taslay3r,

The most straight-forward method is to check for existence of the files and the folders first:

not exists (value of variable “ProgramFiles” of environment) OR not exists (folder ((value of variable “ProgramFiles” of environment) & “\Windows Resource Kits\Tools”)) or (not exists file “subinacl.exe” of (folder ((value of variable “ProgramFiles” of environment) & “\Windows Resource Kits\Tools”))) OR (version of file “subinacl.exe” of (folder ((value of variable “ProgramFiles” of environment) & “\Windows Resource Kits\Tools”)) != “5.2.3790.1180” )

Here is another way to write it that is harder to understand, but easier to write:

not exists files “subinacl.exe” whose (version of it != “5.2.3790.1180”) of folders ((value of variable “ProgramFiles” of environment) & “\Windows Resource Kits\Tools”)

The second way doesn’t give “singular expression refers to non-existent object” because I used the “s” after “file” and “folder”.

I didn’t test this and I might have made a mistake so make sure to double-check the logic is what you want.

Ben

(imported comment written by SystemAdmin)

Thanks Ben! That was exactly what I needed. I did change the != “5.2.3790.1180” to = “5.2.3790.1180” but the form was what I was missing and I really appreciate it. Thanks again.