Using a folder wildcard

(imported topic written by ajdyer200091)

Could anyone help. I’m trying to find out if anyone has folders under my documents on local servers

For instance user names woud be user1, user2, user3 etc.

I tried this but it doesnt like “*” as the wildcard.

unique values of pathnames of parent folders of descendants of folder “c:\documents and settings\user*\mydocuments”

Thanks

Alan

(imported comment written by jeremylam)

Hi Alan,

Try using a whose clause:

unique values of pathnames of folders “mydocuments” of folders whose (name of it starts with “user”) of folder “c:\documents and settings”

(imported comment written by NoahSalzman)

Version 8 also supports wildcards if you use the “find folders” syntax. http://forum.bigfix.com/viewtopic.php?id=5563

(imported comment written by SystemAdmin)

I think the first thing to do would be to write relevance that properly determines what the name of the documents folder would be. From there, it’s simply something like…

exists folder “Documents” whose (exists folders of it) of folders of folder “C:\documents and settings”

However, keep in mind that not every OS uses “documents and settings”, the profiles folder doesn’t have to be on C:\ and the “My documents” folder doesn’t have to be called “Documents” - though probably it is.

So now that I confused you… Unless you’re targeting a specific OS, I’d start dealing with using:

csidl folder 46

which points to where the common documents are located. The last folder in

following text of last “” of pathname of csidl folder 46

shows how the “documents” folder is named on the PC.

parent folder of parent folder of csidl folder 46

shows where the profile is located on the PC

So how about something like…

exists folder (following text of last “” of pathname of csidl folder 46) whose (exists folders of it) of folders of folder (pathname of parent folder of parent folder of csidl folder 46)

Now that you see the last “pathname”, let’s reduce it a tad further…

exists folder (following text of last “” of pathname of csidl folder 46) whose (exists folders of it) of folders of (parent folder of parent folder of csidl folder 46)

And the last parenthesis isn’t technically needed…

exists folder (following text of last “” of pathname of csidl folder 46) whose (exists folders of it) of folders of parent folder of parent folder of csidl folder 46

Maybe the other guys have a more elegant solution. It’s late and I’m going home :slight_smile:

Paul

(imported comment written by ajdyer200091)

Thanks Jeremy Noah and Paul. I really apreciate your help. This is a great forum with very knowlegable people. I’ve gotten alot of help and knowlege from all of you.

Thanks

Alan

(imported comment written by SystemAdmin)

As another thought as was pointed out to me by Daryl, the registry does contain where each profile is located. While there is a default location where new profiles will be created, individual profiles can also be moved across multiple locations/drives/etc. They’re not neccessarily all in the same folder.

Take a look under HKLM\Software\Microsoft\Windows NT\CurrentVersion\ProfileList. In that key, you’ll see a value called “ProfilesDirectory” which points to where new profiles are created. Then under that key will be each key representing the SID of the user. Each one of those should have a value called “ProfileImagePath”, which has the profile directory.

The only caveat is that the specified might include environment variables, so you’d have to use

expand environment string of

on it first.

This one should be more accurate to give you all the paths of the existing profiles on the PC…

folders ((expand environment string of preceding text of last “%00” of (it as string)) of (values “ProfileImagePath” whose ((it as string) does not end with “\systemprofile%00”) of keys whose (exists value “sid” of it) of key “HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\ProfileList” of registry))

Thus combining with how the “documents” folder is named we have…

exists folder (following text of last “” of pathname of csidl folder 46) whose (exists folders of it) of folders ((expand environment string of preceding text of last “%00” of (it as string)) of (values “ProfileImagePath” whose ((it as string) does not end with “\systemprofile%00”) of keys whose (exists value “sid” of it) of key “HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\ProfileList” of registry))

-Paul

(Note after the fact – this can probably be rewritten a bit. Looks like expanding the environment string of a string containing trailing nulls will remove them)