locked
Run as administrator sometimes runs as Admin user sometimes as logged in user RRS feed

  • Question

  • I'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

    Thursday, August 2, 2012 7:16 PM

Answers

  • 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




    • Marked as answer by gc04 Friday, August 3, 2012 2:10 AM
    • Edited by gc04 Friday, August 3, 2012 2:33 AM
    Friday, August 3, 2012 2:03 AM

All replies

  • If 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 2, 2012 8:04 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 2, 2012 9:18 PM
    Thursday, August 2, 2012 8:39 PM
  • Visual 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 3, 2012 12:32 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




    • Marked as answer by gc04 Friday, August 3, 2012 2:10 AM
    • Edited by gc04 Friday, August 3, 2012 2:33 AM
    Friday, August 3, 2012 2:03 AM
  • Yes, 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

    Friday, August 3, 2012 1:11 PM