---
updatedAt: 2025-08-14T13:54:04.000Z
agentTools:
  siteIndex: https://developer.n-able.com/llms.txt
  projectIndex: https://developer.n-able.com/n-sight/llms.txt
---

# Disabling / Enabling All removable devices on Windows

```powershell PowerShell
#PowerShell script for enabled/disabled usb drive 
#Run Only with Run as Administrator (for powershell)
$usb_State = Get-ItemProperty  "HKLM:\SYSTEM\CurrentControlSet\services\USBSTOR"
$cdDvdRom_State = Get-ItemProperty "HKLM:\SYSTEM\CurrentControlSet\services\cdrom" 
Switch ($usb_State.Start)
{
4{Write-Host "USB Drive is Disable" ; $e = (Read-Host "If you want Disabled USB Drive Push E") ; If($e -eq "e") {Set-ItemProperty  "HKLM:\SYSTEM\CurrentControlSet\services\USBSTOR" -name start -Value 3 ; Write-Host "Now USB Drive is Enabled !" -ForegroundColor Red } }
3{Write-Host "USB Drive is Enabled" ; $d = (Read-Host "If you want Disabled USB Drive Push D") ;If($d -eq "d") {Set-ItemProperty  "HKLM:\SYSTEM\CurrentControlSet\services\USBSTOR" -name start -Value 4 ; Write-Host "Now USB Drive is Disabled !" -ForegroundColor Red } }
}
Switch ($cdDvdRom_State.Start)
{
4{Write-Host "CD/DVD-ROM is Disable" ; $e = (Read-Host "If you want Disabled CD/DVD-ROM Push E") ; If($e -eq "e") {Set-ItemProperty "HKLM:\SYSTEM\CurrentControlSet\services\cdrom" -name start -Value 3 ; Write-Host "Now CD/DVD-ROM is Enabled !" -ForegroundColor Red } }
3{Write-Host "CD/DVD-ROM is Enabled" ; $d = (Read-Host "If you want Disabled CD/DVD-ROM Push D") ;If($d -eq "d") {Set-ItemProperty  "HKLM:\SYSTEM\CurrentControlSet\services\cdrom" -name start -Value 4 ; Write-Host "Now CD/DVD-ROM is Disabled !" -ForegroundColor Red } }
}
Read-Host "Push <Enter> for exit!"
```

```json Response Example
{"success":true}
```

# SCRIPT