I'm doing a project in which, from Java, I execute commands from the CMD or Powershell to carry out certain tasks (like, in this case, disable the USB ports of a computer).
I've been looking for information and what really fits what I want to do is enable local group policy:
"Local Computer Policy -> Computer Configuration - > Administrative Templates -> System -> Removable Storage Access -> All Removable Storage Classes: Deny Access to Everything" .
When I enable this policy, it automatically redefines the USB's introduced by applying the changes.
I inspected the changes in the registry that are made when activating this directive and they are, more or less, the ones explained here:
https://thorv.wordpress.com/2013/12/11/habilitardeshabilitar-escritura-y-lectura-de-dispositivos-de-almacenamiento-extraibles/
These changes in the registry can be easily done from the command line, but the problem is that for my PC to take the updated values of HKEY_LOCAL_MACHINE
I have to restart the computer (undesirable situation).
What brings me to the issues:
- Is there a way to change the registry values and that the PC take these updated values without having to restart the computer ?.
- Can I change the local group policies from the command line ?.
- Any other ideas?