WEBINAR: On-demand webcast
How to Boost Database Development Productivity on Linux, Docker, and Kubernetes with Microsoft SQL Server 2017 REGISTER >
Click here for a larger image.
Environment: VC6 SP5, Win2k, Platform SDK
The main purpose of this utility is saving you typing, and of course, a more friendly user interface. Besides,
- You can choose the target desktop on which you want the program to run. I provide the desktop list dialog; you just need to double-click it.
- The button to the left of the password edit box permits you to test your username-password pair correctness.
- The button to the right of the user name edit box will lead to a local machine user list dialog box; you can just choose the user by double-clicking.
CreateProcessAsUser and LogonUser need the following four privileges: SeIncreaseQuotaPrivilege, SeAssignPrimaryTokenPrivilege, SeChangeNotifyPrivilege, and SeTcbPrivilege. By default, the administrator does not have these privileges. You can use the bottom Privilege button to pop up a dialog, set these privileges, and relog yourself. (Yes, you need to relog.) If you dislike this, please go to http://www.codeguru.com/misc/CmdAsUser.html contributed by Martyn "Ginner" Brown.
- When you leave the username and password empty, the program will be launched as "SYSTEM" account.
There is a short list of often-used programs you can choose to "RunAs". The inside code uses the LSA family API to cope with the account privilege, and uses LogonUser and CreateProcessAsUser to do the work. When you ask for a launch as "SYSTEM", more work needs to be done -- open the system process, adjust its token by adding TOKEN_DUPLICATE, TOKEN_ASSIGN_PRIMARY, TOKEN_QUERY right, and reopen it.
In the end, I would like to thank the book Programming Server-Side Applications for Mircosoft Windows 2000 from Microsoft Press, 1999. This program's backbone code is from the sample of the book.
Last note, you need a ReLog to use this utillity. If you add the needed privilege, please push the privilege button first to confirm your current privilege, and it will log you off if you like.
Downloads (MFC Library Dynamic Linked)Download demo executable file - 26 Kb
Download source - 53 Kb