alex
alex

Reputation: 1278

Registry System.UnauthorizedAccessException

when I'm trying to create a subkey in Registry.ClassesRoot I get an System.UnauthorizedAccessException! I'm using win7. Does anyone know why?

Upvotes: 1

Views: 1337

Answers (2)

Itay Karo
Itay Karo

Reputation: 18286

Check that your program run as administrator. By default win7 does not run programs with admin permissions.

Upvotes: 2

Dean Harding
Dean Harding

Reputation: 72658

Because only people in the Administrator group can create keys under HKEY_CLASSES_ROOT.

In general, you shouldn't need to be creating keys under there (if it's part of an install process, then you should probably be using a proper installer with transaction and rollback support - such as Windows Installer - not rolling your own).

But to solve your specific problem, then you need to run your application as Administrator.

Upvotes: 4

Related Questions