Try the following code to see if it helps.
Sub AllowSpecificDevice(deviceInstanceId As String)
' Modify the registry to allow a specific USB device
Dim keyPath As String = "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\USBSTOR\Enum"
' Append the device instance path to the key path
keyPath = System.IO.Path.Combine(keyPath, deviceInstanceId)
' Modify the registry to enable this specific device
Registry.SetValue(keyPath, "Start", 3, RegistryValueKind.DWord)
End Sub
The AllowSpecificDevice subroutine requires the deviceInstanceId parameter, which you would need to obtain by examining the Device Manager or using other methods to identify the specific USB device you want to allow.
Best Regards.
Jiachen Li
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.