create an process with administrator privilege from service in Vista

来源:互联网 发布:sas数据分析 编辑:程序博客网 时间:2024/04/30 10:30

 I did it as the following:
1.Get the session if of the active console user (WTSGetActiveConsoleSessionId)
2.Get the user's token (WTSQueryUserToken),the user has administrator privilege

3.duplicate the token ((DuplicateTokenEx)
4.Get the linked token of ther user token. The linked token has admin privilege.
-----------------------------------------------------------------------------------------------------------------------------------------
TOKEN_LINKED_TOKEN admin;
GetTokenInformation(hUserToken, TokenLinkedToken, &admin, sizeof(TOKEN_LINKED_TOKEN), &len)) ;
 HANDLE AdminToken = admin.LinkedToken;
--------------------------------------------------------------------------------------------------------------------------------------------

5. create the user process (createProcessAsUser)

http://social.msdn.microsoft.com/forums/en-US/vcgeneral/thread/6fcdff4d-7c63-4ea0-b883-5a660ec8d4af
原创粉丝点击