I try to restrict the access to removable storage devices through the Group Policy User Configuration\\Administrative Templates\\System\\Removable Storage Access\\All Removable Storage classes: Deny all access
Accoring to Group Policy Settings Reference for Windows and Windows Server the corresponding registry (and path) is setting a DWORD to 1 (enabled) or 0 (disabled) in HKCU\\Software\\Policies\\Microsoft\\Windows\\RemovableStorageDevices!Deny_All
So far so good. When I try to change these settings through the Group Policy Editor everythings works fine. Even if the removable storage device is plugged in the policy works instantly.
When I try to change the value through the registry itself or using a self-written C# program it doesn't work the policy stays enabled (or disabled).
My C# Code
using (RegistryKey key = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Policies\\Microsoft\\Windows\\RemovableStorageDevices", true))
{
if (key != null)
{
key.SetValue("Deny_All", "0", RegistryValueKind.DWord);
}
}
Console.ReadKey();
Even if I try to update all polices through gpupdate /force
nothing. It's quite the opposite, the old value is set in the registry regardless of whether I'm setting it through hand or through my program. What am I doing wrong?
Thanks in advance!
找到了解决方案:我只是使用meziantou中的代码,该代码来自“ 如何以编程方式将GPO设置为未配置或禁用”
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.