Link to home
Start Free TrialLog in
Avatar of Elime
ElimeFlag for Switzerland

asked on

SHGetKnownFolderPath - Get token of logged on users

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!

ASKER CERTIFIED SOLUTION
Avatar of jkr
jkr
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Elime

ASKER

Yeah I read about that. I'll have to use a processIdTosessionId() in case more than one user is logged on. Seems to be the way to go on that problem. It seems like workaround that's why I was wondering if there was clear solution to this problem. There seems not to be so I'm fine with workarounds :)

Thanks a lot
Avatar of Elime

ASKER

Yeah I read about that. I'll have to use a processIdTosessionId() in case more than one user is logged on. Seems to be the way to go on that problem. It seems like workaround that's why I was wondering if there was clear solution to this problem. There seems not to be so I'm fine with workarounds :)

Thanks a lot