question

WilfredEghenedji-9495 avatar image
0 Votes"
WilfredEghenedji-9495 asked XingyuZhao-MSFT answered

How to Disable and Enable USB using VB.NET

Sorry to ask, if am not violating the policy here: I need source code to enable and disable USB with a button using vb.net. The one have tried creating doesn't to work. Thank you

dotnet-visual-basicwindows-forms
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

XingyuZhao-MSFT avatar image
0 Votes"
XingyuZhao-MSFT answered

Hi @WilfredEghenedji-9495 ,
Also consider changing the registry value:

         ' Disable USB storage
         Microsoft.Win32.Registry.SetValue("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\USBSTOR", "Start", 4, Microsoft.Win32.RegistryValueKind.DWord)
         ' Enable USB storage
         Microsoft.Win32.Registry.SetValue("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\USBSTOR", "Start", 3, Microsoft.Win32.RegistryValueKind.DWord)

Make sure you have administrator privileges.
Best Regards,
Xingyu Zhao


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.


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Castorix31 avatar image
0 Votes"
Castorix31 answered

With SetupDiSetClassInstallParams + SetupDiCallClassInstaller in x64

Many samples on Google


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.