2

I have code to check if the registry does not exist then create it.

Strange thing is, this works perfectly on my windows 7 machine.. If i run it on my windows 10 tablet, it does not work?

I get an Unhandled Exception error:

Access to the registry key: 'HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\EdgeUI' is denied.

My code:

Dim TabletEdgeSwipe As Object = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Policies\\Microsoft\\Windows\\EdgeUI", True)
If TabletEdgeSwipe Is Nothing Then
    Registry.LocalMachine.CreateSubKey("SOFTWARE\\Policies\\Microsoft\\Windows\\EdgeUI").SetValue("AllowEdgeSwipe", "0", RegistryValueKind.DWord)
End If
5
  • Did you try to launch your app in admin?
    – Mederic
    May 30, 2017 at 9:18
  • That solves the issue! Wow. How come that happens on the windows 10 machine and not the win 7?
    – William
    May 30, 2017 at 9:24
  • just depends if the user deactived or reduced the UAC level
    – Mederic
    May 30, 2017 at 9:24
  • Well i have UAC disabled on both win 7 and win 10.
    – William
    May 30, 2017 at 9:25
  • Will just have the app always run as admin, its a app which needs to run on startup and take up the whole screen. So il just set it in properties to always start with admin rights. Thanks for this! Been doing try, catch methods and all sorts to try fix this!
    – William
    May 30, 2017 at 9:26

1 Answer 1

4

A requestedExecutionLevel Problem

This is simply that the application doesn't have the right to access this part of the registry.

You can change the app.manifest

If you can't see the app.manifest

  1. Double Click (MyProject)

  2. Click (View Windows Settings)

Change this line :

<requestedExecutionLevel level="asInvoker" uiAccess="false" />

To :

<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />

This will force the app to be launched or asked to be launched as Administrator


Note:

You could also use:

level="highestAvailable"

The MSDN states:

The application runs with the highest privileges the current user can obtain.

This means that if the user has Admin privileges instead of running it with current security settings it will launch it was maximum available as Admin in our case.

6
  • haha literally just changed that! Searched it up seconds after my last comment. - Thanks again for the help ;)
    – William
    May 30, 2017 at 9:30
  • @irishwill200 No problems make sure marked as answered to finish the question.
    – Mederic
    May 30, 2017 at 9:30
  • Maybe add a note about level: highestAvailable <-- Might be beneficial to some. Will do once im allowed.
    – William
    May 30, 2017 at 9:31
  • Strange thing, with the above done. I still get the denied error! If i run manually with admin rights, it works again.
    – William
    May 30, 2017 at 9:40
  • Make sure you use requireAdministrator also make sure you release your project in correct debug or release folder. Furthermore make sure if your trying in debug mode that Visual Studio is launched as admin.
    – Mederic
    May 30, 2017 at 9:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.