troubleshooting Question

SHGetKnownFolderPath - Get token of logged on users

Avatar of Elime
ElimeFlag for Switzerland asked on
Microsoft DevelopmentSystem Programming
3 Comments1 Solution1612 ViewsLast Modified:
Hey there

My daily business is software deployment, software packaging, installation automation. In order to do so it is often required to put some datas into the userprofile(s) that is (are) currently logged on to the system.

To avoid a logoff (for example when installing via SCCM or other deployment tools) i want to create a little tool that is going to update the current user profile straight away.
(for your info: When deploying an app the current user is a SYSTEM account! NOT the CU of the System)

For now we used a vb script that enumartes through HKEY_USERS, find all SIDS with a "Volatile Environment-Key" and update those (you can get to the profiles folder from this key on too, not only registry).

As this key is not documented and I am writing a C#-App I want to do it properly. Now that seems to be a problem :) In order to "do it properly" I'm supposed to use SHGetKnownFolderPath (Vista and up). There I need the Token of the Users. Which I am not able to get for all logged on users: Only the current user is passed by using System.Security.Principal.WindowsIdentity.GetCurrent(); LsaEnumerateLogonSessions wont give me the needed information and to get a token of a users via WTSQueryUserToken oder others I need higher privleges (LOCAL SYTEM).

That's why I am asking if ANY of you has got an idea that is going to work without a big "walk to the moon and back". I know there are solutions like increasing the privileges and other dirty stuff but if there is another way I'd like to go for it :)

Thanks very much!

Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros