1

I have a need to get the path to the Documents folder, but I need a list of paths, one for each user on the computer, not just the currently signed on User. I don't need the one common Documents folder that is shared by everyone. I need a list of all the user-specific ones.

I have successfully done this for the signed-on user with SHGetSpecialFolderPath, SHGetKnownFolderPath, and SHGetFolderPath without issue.

But is it possible to do this for all User accounts without using impersonation?

Steven Doggart
  • 43,358
  • 8
  • 68
  • 105
NMEwithin
  • 11
  • 2
  • Do you want the common shared path or are you looking to get each user's individual folder? If you need the documents folder that all users share, you can use `Environment.GetFolderPath(Environment.SpecialFolder.CommonDocuments)` – Chris Dunaway Feb 08 '19 at 14:43
  • Hi...I'm looking to get the specifoc Documents folder for each user account on the computer. Not the "AllUsers" path. So say you have 5 users, each with different paths to Documents folder...I need that path for each User account. – NMEwithin Feb 08 '19 at 14:46
  • Possible duplicate of [Get SpecialFolder.MyDocuments folders of each user](https://stackoverflow.com/questions/44945434/get-specialfolder-mydocuments-folders-of-each-user) – Meta-Knight Feb 08 '19 at 15:10
  • Thanks but that solution does not really work as each user documents folder could be different. – NMEwithin Feb 08 '19 at 15:52
  • The registry hive of a User that is not logged in is unmounted. You could get it anyway, using [SHGetKnownFolderPath](https://learn.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-shgetknownfolderpath), acquiring each User's access token. But, is it worth the effort? – Jimi Feb 08 '19 at 16:07
  • Thanks...that was the route that I was going but I'm unsure how to get each user's access token without using impersonation. Is it even possible? – NMEwithin Feb 08 '19 at 16:21
  • [GetKernelObjectSecurity](https://learn.microsoft.com/en-us/windows/desktop/api/securitybaseapi/nf-securitybaseapi-getkernelobjectsecurity). To get the Token handle (and testing the process right to get it): [OpenProcessToken](https://learn.microsoft.com/en-us/windows/desktop/api/processthreadsapi/nf-processthreadsapi-openprocesstoken). I think you'll decide that you don't really need to know the non-current user informations. – Jimi Feb 08 '19 at 17:41

0 Answers0