C#, Windows 8 UAC, and registry edit
Page 1 of 111 Replies - 581 Views - Last Post: 21 January 2013 - 01:13 PM
#1
C#, Windows 8 UAC, and registry edit
Posted 16 January 2013 - 06:47 AM
My application works well on Vista, Win 7 32 and 64 bits.
It modifies some registry key in HKEY_LOCAL_MACHINE.
But when run on Win 8 (both 32 and 64), with minimum level UAC (I drag the slider to bottom, then restart), it doesn't work. And there is the error:
"Application attempted to perform an operation not allowed by the security policy. To grant this application the required permission, contact your system administrator, or use the Microsoft .NET Framework Configuration tool. Requested registry access is not allowed."
When I disable completely UAC of win 8 by editing registry, then restart computer, my application works well.
How can I deal with win 8 UAC enable with c#?
Thank you very much.
Replies To: C#, Windows 8 UAC, and registry edit
#2
Re: C#, Windows 8 UAC, and registry edit
Posted 16 January 2013 - 07:07 AM
#3
Re: C#, Windows 8 UAC, and registry edit
Posted 16 January 2013 - 07:32 AM
#4
Re: C#, Windows 8 UAC, and registry edit
Posted 16 January 2013 - 07:36 AM
modi123_1, on 16 January 2013 - 07:07 AM, said:
Thanks for you reply.
I will continue to work to find out the way to deal with win 8 UAC. It makes me crazy, why doesn't MS keep UAC works like win 7...
Skydiver, on 16 January 2013 - 07:32 AM, said:
I tried it, and also tried <requestExecutionLevel level="highestAvailable" uiAccess="false" />
It doesn't work on win 8 with UAC enabled.
#6
Re: C#, Windows 8 UAC, and registry edit
Posted 16 January 2013 - 11:32 PM
#7
Re: C#, Windows 8 UAC, and registry edit
Posted 17 January 2013 - 07:29 AM
If you have a setting you want to remain the same across all users it would have to go to LocalMachine. For example if a point of sale software was always to open on the second monitor, regardless of which clerk was logged in.
So my question is: What setting are you trying to change? Is it one for your own program or is it a system setting?
You may just have to accept that it is time to stop using the registry for your program's settings. We've done it for decades but as you can see, we're being pushed out of the registry. You might want to start looking at serializing your settings to a SettingsObj class for example. Or using the Application Settings built in to .NET.
Separating data from GUI - PLUS - serializing the data to XML
Easy Application Settings example
#8
Re: C#, Windows 8 UAC, and registry edit
Posted 17 January 2013 - 08:18 AM
#9
Re: C#, Windows 8 UAC, and registry edit
Posted 17 January 2013 - 06:08 PM
tlhIn`toq, on 17 January 2013 - 07:29 AM, said:
If you have a setting you want to remain the same across all users it would have to go to LocalMachine. For example if a point of sale software was always to open on the second monitor, regardless of which clerk was logged in.
So my question is: What setting are you trying to change? Is it one for your own program or is it a system setting?
You may just have to accept that it is time to stop using the registry for your program's settings. We've done it for decades but as you can see, we're being pushed out of the registry. You might want to start looking at serializing your settings to a SettingsObj class for example. Or using the Application Settings built in to .NET.
Separating data from GUI - PLUS - serializing the data to XML
Easy Application Settings example
I try to change my own program setting in registry, and it works well under Vista, Win 7 (UAC enabled). It just has error when running under Win8 (UAC enabled).
Thank you for your suggestion, I'll take a look at serialization.
Additional, this is my code
RegistrySecurity rs = new RegistrySecurity();
RegistryKey rk = Registry.ClassesRoot.OpenSubKey(subkey, RegistryKeyPermissionCheck.ReadWriteSubTree, RegistryRights.FullControl); // Opens the key again with full control.
rs.SetOwner(new NTAccount("newAdmin"));// Set the securitys owner to newAdmin
rs.SetAccessRuleProtection(true, false);
rk.SetAccessControl(rs);// Set the key with the changed permission so Administrator is now owner.
#10
Re: C#, Windows 8 UAC, and registry edit
Posted 17 January 2013 - 08:19 PM
RegistryKey rk = Registry.LocalMachine.OpenSubKey(subkey, RegistryKeyPermissionCheck.ReadWriteSubTree, Registry Rights.FullControl);
Just worrying. . .
#11
Re: C#, Windows 8 UAC, and registry edit
Posted 17 January 2013 - 08:29 PM
b0zhidar, on 17 January 2013 - 08:19 PM, said:
RegistryKey rk = Registry.LocalMachine.OpenSubKey(subkey, RegistryKeyPermissionCheck.ReadWriteSubTree, Registry Rights.FullControl);
Just worrying. . .
Unfortunately, i need to modify the permission inside Classes Root
#12
Re: C#, Windows 8 UAC, and registry edit
Posted 21 January 2013 - 01:13 PM
Why are you trying to change the owner of a registry hive?
|
|

New Topic/Question
Reply



MultiQuote







|