Registry DWord value changing in vb

228 Views Asked by At

I can't change the registry value in vb, please help.

Dim regKey As RegistryKey
        regKey=Registry.CurrentUser.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Policies\System", True)

regKey.SetValue("DisableTaskMgr", 1, RegistryValueKind.DWord)

regKey.Close()

Error

An unhandled exception of type 'System.Security.SecurityException' occurred in mscorlib.dll

Requested registry access is not allowed.

2

There are 2 best solutions below

1
UserNam3 On BEST ANSWER

Execute your application with admins rights :

  • Projet's properties
  • Show Windows parameters (this open app.manifest)

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

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

0
lbndvs On

I got it by opening visual studio as Administrator.