Click here to Skip to main content
15,886,258 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I use VB 2010 and have a problem with reading and writing to the registry via a Limited/standard account. My manifest file looks like the one below but still it does not work. The manifest file is saved as app.manifest, and is stored in the [my Project] folder. What am I doing wrong?



<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestversion="1.0">
<trustinfo xmlns="urn:schemas-microsoft-com:asm.v3"> <security>
<requestedprivileges>
<requestedexecutionlevel>
level="requireAdministrator"
uiAccess="false"/>


Posted
Comments
ledtech3 16-Aug-12 4:43am    
This is a snippet from the page listed below. It was aimed at C++ game developers but the UAC information may be of some help.

Registry access by a standard user is restricted in a similar fashion as the file system. A standard user is permitted read access to all keys in the registry; however, write access is only granted to the HKEY_CURRENT_USER (HKCU) subtree, which is mapped internally to the user-specific subkey HKEY_USERS\Security ID (SID) of current user. An application that needs to write to any registry location other than HKEY_CURRENT_USER requires administrative privileges.

Page this comes from.
http://msdn.microsoft.com/en-us/library/windows/desktop/ee419001(v=vs.85).aspx

1 solution

First of all, you don't want to bypass UAC, really. It is created for a good purpose; and there is nothing wrong with it. You should review your approach.

I think I can tell you what you are doing wrong. Probably you do it correctly (your sample is not clear at all, but I guess I know what is that). It's your understanding of what does it mean might be wrong. Your manifest is configured to instruct OS that the user is required to execute the code as administrator and request the user for confirmation with the "User Account Control" dialog — right away, without a need to run an application with the option "Run as administrator". And in all cases, the user will need to have administrator privileges.

This way, you are probably doing the right thing. But if you thing you can avoid the confirmation at all, it won't work. It would totally defeat the purpose of UAC, come to thing about. You would need to switch UAC confirmations at all, but I won't recommend to do so (this is done via the Control Panel, http://www.mydigitallife.info/how-to-disable-and-turn-off-uac-in-windows-7/[^]; again, don't do it).

Also, you might want to chose a way to disable UAC confirmations just to one or some particular application(s). I would not recommend that, too, but this would be a bit better choice. Please see:
http://kartones.net/blogs/kartones/archive/2008/01/21/kb946932-disabling-uac-prompt-for-certain-apps-not-that-useful.aspx[^],
http://www.techrepublic.com/blog/window-on-windows/selectively-disable-uac-for-your-trusted-vista-applications/635[^],
http://cybernetnews.com/helpful-tip-disable-uac-prompt-for-an-application/[^].

Also, you may choose to use the Microsoft Application Compatibility Toolkit:
http://www.microsoft.com/en-us/download/details.aspx?id=7352[^],

—SA
 
Share this answer
 
v2
Comments
vbGoof 16-Aug-12 5:14am    
Thank you Sergey, but I need to do all that through VB (2010) code. I need to know why my manifest file is not working, is it the file name, the location, needs to be called in the code, etc? I cannot disable UAC on my PC because users who use my app will not know how to disable UAC on theirs.
Sergey Alexandrovich Kryukov 16-Aug-12 12:48pm    
Well, does your manifest is working the way I described? If not, will you show the complete code related to manifest.
--SA
vbGoof 10-Mar-14 14:55pm    
Thanx will look into that
Sergey Alexandrovich Kryukov 10-Mar-14 15:00pm    
Please do, and, after all, don't forget to accept the answer formally (green "Accept" button).
—SA
vbGoof 14-Mar-14 3:57am    
Thanx Kryukov,I cannot disable UAC as it may be a security breach. I tried Microsoft’s Application Compatibility Toolkit, it simply bypasses my manifest. Now i have to think of another way of saving my settings apart from the registry, maybe using a database file. Thanks for your efforts

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900