Correct method to query files/folders in the user's appdata path for analysis?

I have been tasked with determining who has Teams installed and who is actually running it. The below expression seems to work on MOST computers however I am getting the message:

singular expression refers to nonexistent object on some.

if (exists folders “Teams” whose (exists folders “current” whose (exists files whose (name of it = “Teams.exe”) of it) of it) of folder “AppData\Local\Microsoft” of folders (names of current users) of folder “c:\users”) then ( if ( exists process “teams.exe” ) then ( “Running” ) else ( “Not Running” ) ) else (“Not Installed”)

That would have to refer to one of the singulars…the only ones I see there are
folder “AppData\Local\Microsoft”
and
folder “c:\users”

Try changing both of those to folders

1 Like

That did it thanks! This works perfectly now:

if (exists folders “Teams” whose (exists folders “current” whose (exists files whose (name of it = “Teams.exe”) of it) of it) of folders “AppData\Local\Microsoft” of folders (names of current users) of folders “c:\users”) then ( if ( exists process “teams.exe” ) then ( “Running” ) else ( “Not Running” ) ) else (“Not Installed”)

1 Like