VBS Check application data folder for multiple users

1.2k views Asked by At

At my job, we have an application that we use (Mikogo) that installs into the user directory in the App Data folder, instead of into the Program Files folder.

Mikogo has released an update, so I want to find out which computers it is installed on so I can update the software. To do this, I want to parse through a list of computers and check to see if the "Mikogo 4" folder exists within the App Data folder for each user on the computer.

I know how to parse through a list of computers, I know how to check to see if a folder exists, I even know how get the location of the App Data folder... my problem is that I don't know how to get the location of the App Data folder for each individual user on the computer that I am currently checking.

Is there a way for me to check each individual App Data folder?

1

There are 1 answers

1
Ansgar Wiechers On

Something like this might do:

Const regProfilesDir = "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\ProfilesDirectory"
Const appDataDir     = "AppData\Roaming"

Set sh  = CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")

profilesDir = sh.ExpandEnvironmentStrings(sh.RegRead(regProfilesDir))

For Each user In fso.GetFolder(profilesDir).SubFolders
  If fso.FolderExists(fso.BuildPath(user.Path, appDataDir & "\Mikogo 4")) Then
    WScript.Echo "Application folder exists for user " & user & "."
  End If
Next

However, Windows versions prior to Vista used a different name for the AppData folder, and the name was localized too. If you have older Windows versions in your environment, you'll have to handle that as well.