create an process with administrator privilege from service in Vista
2012-02-17 13:22
423 查看
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
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
相关文章推荐
- ANR in an IntentService with its own process
- How to create an XTR file from XML in Delphi XE4 using XML Mapper?(delphi中如何通过xmlmapper创建xtr文件)
- Remote Thread Execution in System Process using NtCreateThreadEx for Vista & Windows7
- 在cmd窗口输入命令遇到You must run this command from a command prompt with administrator privilege怎么办?
- iOS- Please sign in with an app-specific password. You can create one at applied.apple.com.
- NAMESPACE_ERR: An attempt is made to create or change an object in a way which is incorrect with regard to namespaces.
- MSMQ&Com+ Service: How to create an Com+ Service in .NetFramework
- BDNtv: Deriving a model from an existing database with ECO II in Delphi 2005
- [转]Work With Odata in Web API: Create Your First Odata Service
- Populate A List Item With Record Group In Oracle Forms Using Populate_List And Create_Group_From_Query Command
- Create an avatar and chat with your friends in rooms you design
- Create an ASP.NET web app in Azure App Service
- Xcode添加账号提示Please sign in with an app-specific password. You can create one at appleid.
- Populate A List Item With Record Group In Oracle Forms Using Populate_List And Create_Group_From_Query Command
- How to get the password text in a text with password property from another process using C++ - 用C++如何从不同进程获取密码框文本
- [D3] Create Labels from Numeric Data with Quantize Scales in D3 v4
- Using a Service Locator to Work with MessageBoxes in an MVVM Application
- [D3] Create Labels from Non-numeric Data with Ordinal Scales in D3 v4
- How to Run a Program as an Administrator in Windows 7
- How to create physical standby database with 11g RMAN DUPLICATE FROM ACTIVE DATABASE [ID 747250.1]