Run as administrator sometimes runs as Admin user sometimes as logged in user
-
Thursday, August 02, 2012 7:16 PMI'm running Windows 7 x64, it has two user accounts, the default Admin user with administrator priveleges and a Greg user with standard user privelages. I have a program that reads and writes some HKCU registry keys, if I log in as Greg and run the program normally, the HKCU points to the registry entries for user Greg. Sometimes, while logged in as Greg, if I run the program with "Run as administrator", it uses HKCU registry entries for user Greg and sometimes it uses HKCU registry entries for user Admin. I'm not sure what triggers the change, it seems like it may happen after a windows update, or after changing user account settings. Anyone have an idea of what's going on?
Greg Christensen
Enigma Industries
All Replies
-
Thursday, August 02, 2012 8:04 PMIf you run the program over the shoulder (logged in as greg then elevated to the admin user) then you will write to admin's HKCU, not greg's.
The following is signature, not part of post
Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
Visual C++ MVP -
Thursday, August 02, 2012 8:39 PM
It was working like you suggest this morning, then I switched the user account types a couple of times and reset the computer. Now I'm seeing this. Here I've set Visual Studio 2005 to Run as administrator, and you can see it is running as user Greg. Greg is a standard user and Visual Studio does seem to have administrator privelages.
Greg Christensen
Enigma Industries- Edited by gc04 Thursday, August 02, 2012 9:18 PM
-
Friday, August 03, 2012 12:32 AMVisual Studio has special code to sync settings (e.g. most recent projects) across elevation. Try another program.
The following is signature, not part of post
Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
Visual C++ MVP -
Friday, August 03, 2012 2:03 AM
Looks like it's a bu... I mean feature. To recreate, set both users to administrator with no password, restart the computer. Log in as Greg, set Greg to a standard user, don't restart computer, then run any app as administrator.
Greg Christensen
Enigma Industries
-
Friday, August 03, 2012 10:22 AM
Maybe elevation actually works this way?
When the current user is administrator, Run as administrator just uses the current account, but elevated (the admin carma enabled). Why to use a different Administrator account?
It's too ***ing complicated, I never could understood it clearly, like, say, sudo :(
-- pa
-
Friday, August 03, 2012 1:11 PMYes, if the current user is an administrator, a program Run as administrator runs under the current user's name. The problem I'm seeing is if you change the current user's type to standard user, the current user remains an administrator until the next restart.
Greg Christensen
Enigma Industries -
Monday, August 06, 2012 1:52 AM
This looks like a bug... but could actually be a deliberate behaviour covering something even worse, like described here(see slide #8).
-- pa
- Edited by Pavel A Monday, August 06, 2012 1:52 AM


