Finding out if the logged-on user has Teams installed and running

How would I incorporate the first relevance that identifies from the registry the profile path of the currently logged on user with the second analysis property for whether Teams is installed for the logged on user and if they are running it? The Teams property works for the most part but if the username has been changed since they first logged onto the system (maiden name changed to married name for example) it fails.

value "ProfileImagePath" of keys whose (name of it = (component string of sid of logged on user whose (active of it = True) as string)) of key "HKLM\Software\Microsoft\Windows NT\CurrentVersion\ProfileList" of native registry as string

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 (name of logged on user whose (active of it = True)) of folders "c:\users") then ( if ( exists process "teams.exe" ) then ( "Running" ) else ( "Not Running" ) ) else ("Not Installed")

I wonder if using the csidl folders might be of use

Q: exists csidl folder 28 whose (not exists file "teams.exe" of folder "\Microsoft\Teams\current" of it)
A: False
T: 1.719 ms
I: singular boolean

Folder 28 is CSIDL_LOCAL_APPDATA so should redirect to the logged in user. You may need to add logic to cater from no logged in user or multiple logged in users

1 Like

On my computer that folder resolves to the following. Iā€™m not sure if thatā€™s the path we are looking for is it?

q: csidl folder 28
A: C:\Windows\System32\config\systemprofile\AppData\Local
T: 0.015 ms

Narrowing this down this works:

exists folders "Teams" whose ( exists folders "current" of it ) of folders "AppData\Local\Microsoft" of folders ( value "ProfileImagePath" of keys whose ( name of it = ( component string of sid of logged on user whose ( active of it = True ) as string ) ) of key "HKLM\Software\Microsoft\Windows NT\CurrentVersion\ProfileList" of native registry as string )

This does not work

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 ( value "ProfileImagePath" of keys whose ( name of it = ( component string of sid of logged on user whose ( active of it = True ) as string ) ) of key "HKLM\Software\Microsoft\Windows NT\CurrentVersion\ProfileList" of native registry as string )

I do like using the ā€˜csidl folderā€™ inspectors to retrieve many of the well-known folder paths on Windows (like ā€˜publicappdataā€™ ), but the ones that depend on a user context may not give the result you want. The value ā€˜csidl folder 28ā€™ gives is for the AppData folder of the LocalSystem user account, not the AppData folder of the logged-on user.

Retrieving the ProfileImagePath is reliable, but I think home directory folder of <user> may be simpler. What makes it slightly confusing is that ā€˜userā€™ and ā€˜logged on userā€™ are actually distinct types, so to get the home directory folder reference one must use home directory folders of users of logged on users

q: (name of it, home directory folders of it) of users of logged on users
A: jwalk, C:\Users\jwalk

We can also shorten this particular query a bit by listing the whole ā€œknown portionā€ of the folder/file path in one string. I donā€™t have Teams.exe in that path on my machine, but hereā€™s an example using another file I do have

q: exists files "AppData\Local\Microsoft\WindowsApps\msteams.exe" of home directory folders of users of logged on users
A: True

q: pathnames of files "AppData\Local\Microsoft\WindowsApps\msteams.exe" of home directory folders of users of logged on users
A: C:\Users\jwalk\AppData\Local\Microsoft\WindowsApps\msteams.exe

edit: note there are two very similar inspectors, home directory of <user> gives a string describing the path, while home directory folder of <user> gives an actual folder object.

1 Like

For some reason it is evaluating to false even though the file is in the correct path:

What does this return?

q: pathnames of home directory folders of users of logged on users

In the Fixlet Debugger, this probably needs to run in ā€˜local client evaluation modeā€™ in order to retrieve logged-on users

q: pathnames of home directory folders of users of logged on users
T: 0.000 ms

Have you tried setting the Fixlet Debugger to ā€˜Evaluate using Local Clientā€™?

I apologize for the late reply. Yes I was using the Local Client to evaluate. I will try it on another computer to see if it behaves differently. Iā€™m on the 10.3 client on Windows 11 so maybe that is the issue?

Maybe? I could check later whether that was a problem with that specific versionā€¦but this inspector was introduced in 9.5.0ā€¦Iā€™ve been using the 10.0.9 client & Debugger on Win10 and Win11 to check this

Hm Windows 11 support was officially introduced on the 10.0.4 client so that could well be it. Iā€™d try upgrading at least one client and see whether that resolves it.

any issues with upgrading the clients ahead of the main server and/or relays?

We had a 10.0.1 infra and were upgrading Win11 clients to 10.0.5 with no issues

1 Like

After upgrading the client (and debugger) the fixlet debugger still does not display the correct info.

Does it return anything? You canā€™t run it in local QNA mode as it will error

It needs client mode (this from my Win11 test machine with 1 local and 1 RDP user session logged in)

Yes this is in Local Client mode:

q: pathnames of home directory folders of users of logged on users
T: 0.000 ms

Weird. Wonder if which part is failing can be narrowed down with the following

Q: number of logged on users
A: 2
T: 0.017 ms

Q: exists logged on users
A: True
T: 0.017 ms

Q: exists users of logged on users
A: True
T: 0.016 ms

Q: exists home directory folders of users of logged on users
A: True
T: 0.019 ms
Q: number of logged on users
A: 1
T: 0.019 ms

Q: exists logged on users
A: True
T: 0.018 ms

Q: exists users of logged on users
A: False
T: 0.021 ms

Q: exists home directory folders of users of logged on users
A: False
T: 0.030 ms

What type of user is logged on ( Local, Domain, AAD, Microsoft Account? )