0

In my console application I need to retrive some information about last connected time and last disconnected time about USB devices.

To do this I need to access to properties{83da6326-97a6-4088-9453-a1923f573b29} subkey foreach key in "Computer\HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Enum\USB\"

Below image explain what I mean and where I'd like to access: enter image description here

What I have tried is below code:

RegistryKey reg = Registry.LocalMachine;
RegistryKey subKey=reg.OpenSubKey(@"SYSTEM\ControlSet001\Enum\USB\ROOT_HUB30\4&2ae8b031&0&0\Properties");

But I have a Security Exception. Any idea?

  • Are you running in an elevated process? – Nathan M Aug 05 '22 at 22:30
  • yes. I noticed that I have the same access problem with Windows registry and Powershell with admin privileges. – Antonio Argentieri Aug 06 '22 at 08:20
  • Well, let's validate that you can read anything from HKLM in the registry. So try grabbing some not-so-sensitive looking values, and validate that you have access more broadly. If not, then that will tell you what you need to concentrate on researching. If it DOES, then this specific key might be open by another process... Another thing to think about is... Is this a work machine? There might be a group policy constraint your company sets. – Nathan M Aug 06 '22 at 15:00

0 Answers0