No announcement yet.

How to disable USB Drives (jump/flash/external/etc.)

This topic is closed.
This is a sticky topic.
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to disable USB Drives (jump/flash/external/etc.)

    This explains how to disable ONLY USB storage devices(flash/Jump/external HD's) completely without disabling keyboards, mice, etc.

    I decided to go this route after trying every other option I could find on the internet. So far this is the only way I have found to completely kill USB drives without ways to get around restrictions. edit: WITHOUT PURCHASING THIRD PARTY SOFTWARE

    First thing to do is this:

    1.Run regedit and navigate to HKLM\system\currentcontrolset\services\USBstor.

    2.Change the value of the dword "Start" from 3 to 4. If the dword "Start" doesnt exist, create it. This will prevent a previously installed USB device from loading when the device is plugged into the machine. ((As most of you know this a Microsoft suggestion, which does work perfectly at disabling previously installed devices, however, this alone will not disable USB storage completely. If a user plugs a new USB storage device into the machine the device will install and the dword value will be reset to 3. Now if you incorporate adding this into a script it alone will disable USB drives, but only after a user plugs a device in, removes it without uninstalling it, logs off then logs back on, thereby running the script. This means that there is a window of opportunity for users to have access to new devices, this may be acceptable for some, but not for others.))

    3. The next thing to do is to change the permisions on the USBSTOR key. You need to DENY full control on the "system" group.

    ((What this does is denies everyone the ability to access the USBStor key, effectively killing the ability for any user (including admins) to install USB storage devices. Now the reason you deny the "system" group is because windows will use this account if no one is logged onto the machine yet. What I mean by this is if say you want to deny a group of users called "staff", you would need to deny them using GP or a logon script. This will work great, but, if a "staff" group user plugs a USB drive in before logging in to Windows the device will be installed using in the backgroud using the "system" group, then when the user logs in the "staff" group policy is applied dening the user access to the USBstor key, but by this point it makes no difference because the devices is already installed and accessible and once a device is installed the usbstor key is no longer used.))

    3. So now that these two steps are are done, *NO ONE* will be able to install USB drives.

    If a user tries to use a previously installed drive the device will be blocked and nothing will happen, no prompts, nothing. This is accomplished through step 1, the dword value.

    What happens if a user plugs in a "New" device that was not previously installed, the hardware wizard will run, asking for the location of drivers. Regardless of whether a user selects the "automatically" search and install or if they attempt to manually install 3rd party drivers, the HW wizard will prompt the user that "access is denied" once the drivers are selected. This is the result of step 2, denying "system".

    Now that we know how to disable USB storage devices we need to find an efficient way to do this without driving through the registry on each and every machine.

  • #2
    part 2


    This is what I did to accomplish this method of killing USB drives quickly and easily.

    I created 2 batch files, 1 batch to disable and another for administrators(tech support, ie.) that will re-enable USB drives if the need arises.

    1: First thing is to get a copy of the tool "subinacl.exe". This tool is included with MS Server 2003 RK.

    ((What subinacl allows you to due is set specific permissions on the exact group or user, etc.. that you need to, this includes permissions on registry Keys which is what we will be doing.))

    2: Once you have a copy of "subinacl.exe" set up a folder for your batch files. In my particular case I wanted these batch files available on the network so I created a shared folder named "DisableUSB" on a server. Next I created a subfolder within "DisableUSB" called "subinacl". Put a copy of "subinacl.exe" in this folder.

    3. Next thing to do is create 2 “reg” files in the subfolder “subinacl”. I named the 2 files “dword3.reg” and “dword4.reg”. These files are going to be used to change the value of the dword “start” in the registry key Usbstor.

    I assume most probably know how do create reg files, this is what should be in the files:

    For “dword3.reg”
    Windows Registry Editor Version 5.00

    [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Servic es\USBSTOR]

    *change the 3 to a 4 for “dword4.reg”*

    4. Now put these 2 files in the “subinacl” folder if they weren’t created there.

    OK, all the pieces should now be in place. For this example we have a shared folder (on no particular server) called “disableUSB”. Within this folder is a subfolder “subinacl” that has subinacl.exe, dword3.reg, and dword4.reg within it.

    5 . Now to create the 2 batch files. I created these 2 files under the main share folder (disableUSB). One is called “disableUSBdrives.bat” which, you guessed it, disables drives, and the other for re-enabling drives, “enableUSBdrives.bat”. Wow…

    This is how disableUSBdrives.bat is set up:

    @echo off
    regedit /s \\servername\disableUSB\Subinacl\dword4.reg
    \\servername\DisableUSB\Subinacl\subinacl.exe /keyreg \system\currentcontrolset\services\usbstor /deny=system
    echo **USB drives disabled**

    *the path will differ of course. \\servername is just an example.

    for “enableUSBdrives.bat” simply change change “dword4.reg” to “dword3.reg” AND “deny=system” to “grant=system”

    Notice that the only real meat to these batch’s is running regedit and running subinacl. Everything else (cls,pause,echo) is optional, for my particular situation it was needed.

    6. Go the machines that you want to disable USB drives on and run the disableUSBdrives batch from the network share.

    And that’s it. USB drives gone.

    Now of course running a batch from each machine is still time consuming, but In my particular situation it had to be done this way, and is obviously much faster than driving through the registry.

    The most efficient way to incorporate this would be with logon scripting. Unlike with just using the dword start=4 trick, after this script is run, there is no way for joe blow user to use any of his nifty little Jumpdrives or his hot new hard drives.

    Also note that folder names and locations can be set up in any way and anywhere as long as the batch files point to the right place.

    Anyway. hope this helps someone.


    • #3
      NICE!! Thanks for that.
      Joined: 23rd December 2003
      Departed: 23rd December 2015


      • #4
        FYI: there is a new KB about the subject:;en-us;555324
        Guy Teverovsky
        "Smith & Wesson - the original point and click interface"


        • #5
          Re: How to disable USB Drives (jump/flash/external/etc.)

          I have tried the method in this post to no avail. I am having trouble with the subinacl command. Nothing I try seems to work with this utility, I have downloaded the subinacl.exe file from the Server 2003 resource kit.

          In the batch file one of the commands I am typing is:

          SUBINACL /KEYREG \\W20863 \HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Servi c
          es\USBSTOR /DENY=system=R

          I have tried various syntax of this command. ie without the R on the end of the line, with or without the the computername "W20863".

          When I run the above command, this is the output I get:
          +KEYREG \\W20863\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlS et\Services\USBSTOR

          Elapsed Time: 00 00:00:00
          Done: 0, Modified 0, Failed 0, Syntax errors 0

          I don't understand what is happening. I don't get any sucess messages or failures by the look of it, so am finding it hard to know whats going wrong. BTW my PC is Windows XP SP2. Can someone also confirm if Subinacl works on all versions of Windows 2000 and XP?


          • #6
            Re: How to disable USB Drives (jump/flash/external/etc.)


            Why not just follow the link provided by Guy, copy the text and import the group policy template? Once you do that remove the check to only show fully managed settings. View->Filtering

            Use gpedit.msc if you're not on a domain.

            ** Remember to give credit where credit is due and leave reputation points sigpic where appropriate **


            • #7
              Re: How to disable USB Drives (jump/flash/external/etc.)

              I've created a few pages that'll help you configure these tettings. More will come later.

              Disable USB Disks
              Disable USB Disks with GPO
              Disable Writing to USB Disks in XP SP2
              Disable Writing to USB Disks with GPO

              See the front page of for links to the above articles.

              Daniel Petri
              Microsoft Most Valuable Professional - Active Directory Directory Services
              MCSA/E, MCTS, MCITP, MCT


              • #8
                Re: How to disable USB Drives (jump/flash/external/etc.)


                In the article Disable Writing to USB Disks in XP SP2.. You state to find the key:

                HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Contro l\StorageDevicePolicies

                I do not have a StorageDevicePolicies under Control.. Has something changed since your articles were posted?


                Originally posted by danielp
                I've created a few pages that'll help you configure these tettings. More will come later.

                Disable USB Disks
                Disable USB Disks with GPO
                Disable Writing to USB Disks in XP SP2
                Disable Writing to USB Disks with GPO

                See the front page of for links to the above articles.


                • #9
                  Re: How to disable USB Drives (jump/flash/external/etc.)

                  create StorageDevicePolicies

                  Thank you
                  Joined: 23rd December 2003
                  Departed: 23rd December 2015


                  • #10
                    Re: How to disable USB Drives (jump/flash/external/etc.)

                    Greetings. This is my first post even though I have been a reader for several years. I just haven't had to ask anything because everything seems to be answered.

                    Has anyone attempted to try this as a user policy instead of a computer policy yet? I implemented the computer policy with the custom .adm method and it worked like a charm. Now, I have need for this to be on a per-user assignment instead of micromanaging several OU's.

                    I had a thought as I was posting this and I will report the results of my testing.


                    • #11
                      Re: How to disable USB Drives (jump/flash/external/etc.)

                      In my testing environment I deployed the custom .adm file via GPO in AD. It works great until I connected an external DVD drive. After I removed the DVD drive from the USB port then the USBSTOR driver got enabled again and now I am able to connect any USB storage device to the computer. I rebooted the computer and the GPO is not applying anymore. I waited for replication on the domain and the GOP is not working on this particualr computer anymore. The value on the registry key got changed back to 3. The only way to make work again was by removing the computer from the group where the GPO was being applied to and adding it back in.


                      • #12
                        Re: How to disable USB Drives (jump/flash/external/etc.)

                        Hey guys, first post here. I looked at the batch script above, and I find VBscript easier and more full featured. Below is the source for a .vbs to toggle USB flash drives on/off. I have thoroughly tested it on XP, but you may want to add error checking through the err mthod, or OS detection through the expandenvironmentstrings method. A quick Google search on either will return anything you need. Also, if you like VBScript, or want to learn more about it, go to " (DevGuru) for reference.

                        Remember that you need administrative privileges to change this registry key, unless you have changed the permissions already.

                        If you want to you can cut and paste the routine into two separate .vbs files, but remember to include all of the functions at the bottom.

                        Have the fun!


                        ‘BEGIN MAIN
                        Option Explicit
                        Dim sRegKey, sKeyExist
                        sRegKey = "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Servi ces\UsbStor\Start"

                        sKeyExist = keyExist(sRegKey)
                        If sKeyExist <> FALSE Then
                        If sKeyExist = "3" Then
                        'Disable USB Storage Drives
                        RegWrite sRegKey, "4", "REG_DWORD"
                        ElseIf sKeyExist = 4 Then
                        'Enable USB Storage Drives
                        RegWrite sRegKey, "3", "REG_DWORD"
                        End If
                        End If

                        END MAIN
                        'Check if a specific key exists; if so, return value, else return bool(FALSE)
                        Function keyExist(strRegKey)
                        dim oShell, strOldName
                        set oShell = CreateObject("Wscript.Shell")
                        ' Turn error detection off
                        On Error Resume Next
                        ' Read Key; set Key Value IF exist, ELSE FALSE
                        strOldName = OShell.RegRead(strRegKey)
                        If Err.number = 0 Then
                        keyExist = cInt(strOldName)
                        keyExist = FALSE
                        End If
                        ' Turn error detection back on
                        On Error Goto 0
                        Set oShell = Nothing
                        end function

                        'Write a registry value
                        Private Sub RegWrite(byVal regpath, byVal strToWrite, byVal regType)
                        Dim objShl
                        Set objShl = CreateObject("")
                        On Error Resume Next

                        'if the registry key is numeric, convert to integer; else, write as the type specified
                        if IsNumeric( strToWrite ) Then
                        objShl.RegWrite regpath, CInt( strToWrite ), "REG_DWORD"
                        objShl.RegWrite regpath, strToWrite, regType
                        end if
                        If Err Then Err.Clear
                        On Error GoTo 0
                        Set objShl = Nothing
                        End Sub


                        • #13
                          Re: How to disable USB Drives (jump/flash/external/etc.)

                          I've used this GPO to disable write access to USB drives..

                          Will this affect USB devices such as scanners and printers??



                          • #14
                            Re: How to disable USB Drives (jump/flash/external/etc.)

                            Someone is copying the whole tutorial and posting on his site and in other forums without giving any credit to original author and original source!

                            On his website:


                            In forums:


                            I hope you guys will take some action and teach him a lesson so that he'll never do this again in future. Thanks.


                            • #15
                              Re: How to disable USB Drives (jump/flash/external/etc.)

                              Thanks Serial. We appreciate you bring this to our attention.
                              Joined: 23rd December 2003
                              Departed: 23rd December 2015