0

Who to disable enable usb port while mouse keyboard not disable vb.net? I want to make an application which run on every computer and disable USB port? "But keyboard mouse not disable", application will be run by administrator with use of password no one will enable after that enable USB port.

"Also every time new usb device plug into computer software auto run and block it" Is there any possibility to do so?

Here i try below code and got error"{"Requested registry access is not allowed."}" in this line of code regKey = Registry.LocalMachine.OpenSubKey("SYSTEM\CurrentControlSet\Services\USBSTOR", True) ?

Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
    '  Me.WebBrowser2.Document.InvokeScript("showJavascriptHelloWorld")
    Dim regKey As RegistryKey
    Dim ver As Decimal
    'opens the path USBSTOR from regedit
    If rtb.Checked Then
        If MsgBox("All USB Ports Will Be Disabled Except The Presently Connected Ports (Ex.,USB Mouse,Printer etc !) ", MsgBoxStyle.OkCancel, "ARE YOU SURE ?!") = MsgBoxResult.Ok Then
            regKey = Registry.LocalMachine.OpenSubKey("SYSTEM\CurrentControlSet\Services\USBSTOR", True)
            regKey.SetValue("Start", 4) ' 4(To disable the ports)
        End If
    Else
        regKey = Registry.LocalMachine.OpenSubKey("SYSTEM\CurrentControlSet\Services\USBSTOR", True)
        regKey.SetValue("Start", 3) ' 3(To enable the ports)
        MsgBox("Ports Are Enabled !", MsgBoxStyle.OkOnly)

    End If
End Sub
Skatox
  • 4,237
  • 12
  • 42
  • 47
Sonia Rehman
  • 95
  • 3
  • 12
  • What above error are you talking about? – Saragis Jul 25 '15 at 10:29
  • @Saragis sory i forgot updated question Here i try below code and got error"{"Requested registry access is not allowed."}" in this line of code regKey = Registry.LocalMachine.OpenSubKey("SYSTEM\CurrentControlSet\Services\USBSTOR", True) ? – Sonia Rehman Jul 25 '15 at 10:49
  • Have you tried this? http://stackoverflow.com/questions/562350/requested-registry-access-is-not-allowed – Rosdi Kasim Jul 25 '15 at 13:41

0 Answers0