How to access the value of "Run this program as an administrator" in file's Properties>Compatibilty>"Privilege Level"
-
Thursday, May 19, 2011 8:20 AM
On Windows 7, in file's Properties>Compatibilty>"Privilege Level", there is a checkbox "Run this program as an administrator". Can I access it by VB.Net?
All Replies
-
Friday, May 20, 2011 3:11 AMModerator
It is set and stored in the registry keys. You could access the keys:
HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers
which stores the informatino about the compatibilty of the files in your OS.
If one file is set "Run this program as an administrator", the registry key for this file will have the value data: RUNASADMIN
Sincerely,
Bob Bao [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.

- Proposed As Answer by Bob_BaoMVP, Moderator Friday, May 20, 2011 3:11 AM
- Marked As Answer by dcba63 Friday, May 20, 2011 7:23 AM
-
Friday, May 20, 2011 7:23 AMThank you very much.
-
Tuesday, August 02, 2011 5:21 AM
Hi,
If I manually add an entry for any file under "HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers" will it work.
I mean I am an entry under the specified registry location for an exe, so from next time will the exe runs as an admin all the time?
regards
Seshu
-
Tuesday, August 02, 2011 5:25 AMModerator
It is under the HKEY_CURRENT_USER , so if you do not change your account, it can run as admin always in your current account.
Bob Bao [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.

-
Tuesday, August 02, 2011 5:50 AM
Hi Bob,
Thanks for the quick reply.
If add an entry under 'HKEY_CURRENT_USER " that will be user specific, but how can I make it as a machine specific..
-
Tuesday, August 02, 2011 6:00 AMModeratorUse Application Compatibility Toolkit (ACT) to apply one compatibility mode on your specific application. http://www.microsoft.com/download/en/details.aspx?id=7352
Bob Bao [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.

-
Tuesday, August 02, 2011 12:03 PM
Bob,
I am working on Windows 2008 R2 Operating System...
My question is, If I add a USER Specific entry it is working fine, But when Add it for HKEY_LOCAL_MACHINE it is not working.
I dont understand How ACT will help in this situation.
Please let me know why is it not working for Machine level.
Is there any other things I have to do for Machine specific.
Regards
Seshu
-
Tuesday, August 02, 2011 1:28 PMModerator
For machine level, you could use ACT to apply one compatibility mode, or you could change the application manifest. I recommend you to read the Application Compatibility Toolkit (ACT) document and learn how to use it. HKEY_LOCAL_MACHINE cannot help you.
Application Compatibility Toolkit (ACT) : http://technet.microsoft.com/en-us/library/cc722055(WS.10).aspx
Bob Bao [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.

-
Wednesday, August 03, 2011 6:10 AM
Bob,
I did not get any related information in ACT, and more over ACT is not supported on "Important ACT is not supported on Windows Server 2008 nor is it supported on Windows NT."
First let me explain the exact need what I'm looking for.
We are working on Windows 2008 Operating System.
We have an exe, and that exe is called at the time of UN-installation/installation of patch. While un-installing patch the corresponding exe is not running with Admin privileges. So I thought of setting the Admin Privileges using registry.
If I add the registry entry under HKEY_CURRENT_USER, it is working fine for the logged in user. But If I add the registry entry under HKEY_LOCAL_MACHINE it is not working,
If I manually set the privilege level for that particular file(Change settings for all Users) it is adding a registry entry under HKEY_LOCAL_MACHINE. But if I add the same registry entry manually why is not setting the privilege levels.
Please let me know what should I do.
-
Wednesday, August 03, 2011 3:56 PMModerator
If this application is designed by you, I recommend you to add the manifest into it, and enable the UAC setting in it to run it as admin.
If it is not, then please try this forum for windows server ITPro forums on Technet: http://social.technet.microsoft.com/Forums/en-us/category/windowsserver
Bob Bao [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.



