Three types of Diskpart clean errors
Diskpart is a powerful
Windows built-in utility that can help you to clean or format hard drive or USB
drive with ease. In most cases, your hard drive or USB drive is able to be cleaned successfully under the help of Diskpart utility. But it is possible that the disk
clean operation can’t be completed due to some errors and common three errors are
listed below:
Diskpart has encountered an error: Access is denied.
Diskpart has encountered an I/O device error.
Diskpart has encountered an error: the media is write-protected.
Effectively fix differential errors occurred to Diskpart
Since three common Diskpart clean errors have been described in the previous
paragraph, the corresponding solutions will be presented in the following text.
✔ Fix access denied error
✔ Fix I/O device error
✔Fix media write protected error
✔ Fix access denied error
When you receive the message that Diskpart has encountered an error: Access is
denied, it means that your hard drive or USB drive is thought to be non-authorized
or blocked.

At first, you can check the System Event Log to get more information: Click “Start”
icon > Enter “eventvwr”> Press “Enter” > Click “Windows Logs” > Click
“System” and you can look for RED circles for Errors and Critical > Click one
> choose “Details and General” Table to gain more detailed information. You may find that you didn’t run command prompt as administer. Then you can type “cmd” and press “Crtrl+Shif+Enter” to run command prompt as administrator.
✔ Fix I/O device error
If the Diskpart clean failed due to I/O device error, it is a lit bit complicated as this error could be caused by different events such as inappropriate connection,
incompatible transfer mode, damaged hard drive or USB drive and so on. Therefore,
what you should first is to check the connection of the device. Having confirmed
that the device connection is OK, you can try to clean your device again with
Diskpart. If
the error message that Diskpart has encountered an I/O device error still appears, you
might consider that whether the transfer mode for your device is correct or there is something wrong with the device. Take measures as the steps given below:
1. Press “Windows + R”, type “devmgmt.msc” to enter Device Manger.
2. Then click “IDE ATA/ATAPI controllers” to expand it.
3. Right-click the channel where the device that you need to clean (usually, it is
secondary IDE Channel) is connected
4. Choose “PIO Only” in the Transfer Mode Box for the proper device. Then, click “OK”
and exit all windows.
5. Restart the Computer and observer whether the error is fixed.
If the problem still exists, you can try to check your device through the following
steps: Double Click “This PC” > Right-click the target drive and select
“Properties” > Click on Tools Tab and click “Check” icon. Then the file system
errors or bad sectors that cause I/O device error will be resolved.
✔ Fix media write protected error
When the error message Diskpart has encountered an error: the media is write-protected appears, it means that your files on the device can’t be deleted or rewritten. You need to fix this error if you want to clean the drive.
If your device is USB drive that owns a physical read-only switch, you shall check
the switch and put it to “OFF” side. Then, you can clean or format the USB drive with Diskpart. If not, you can skip this operation and try one or more
solutions listed below:
Solution 1. Disable write protection via
Diskpart
1. Press “Windows + R” and enter “diskpart” in the pop-up box. Then hit “Enter”
key.
2. Type the following command and hit “Enter” in order:
“list disk”> “select disk n”, where n is the number of the target disk >“attribute disk clear readonly”

Solution 2. Edit the registry
1. Press “Windows + R” and input “regedit”. Then, press “Enter”.
2. Navigate to the following paths:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\StorageDevicePoliceies
3. Double click the “WriteProtect” Key and change the value to 0 in the pop-up
window. Click “OK”.

Solution 3. Format drive via professional partition tool
When the two solutions are invalid, this error appears might due to corrupted file
system. It is recommended to format the drive with a reliable third-party partition tool AOMEI Partition Assistant Standard. It can format drive with corrupted file successfully within a few steps and very easy to handle.
Step 1. Right-click the drive that you intend to format and choose
“Format partition”.

Step 2. Determine the file system and cluster size. Click “OK”.

Step 4: Click “Apply” to complete the operation in the main user
interface.

✍ Notes:
◆ The time spending on formatting is depended on the data of your hard drive or
USB drive.
◆ It is available to zZero fill hard drive via AOMEI Partition Assistant Standard.
◆ It is compatible with Windows 10, 8, 7, XP, and Vista. If you are using Windows Server 2049, 2016,2012 (R2), 2008 (R2), or 2003, please use AOMEI Partition Assistant Server.
Verdict
When Diskpart clean error appears, calm down, and take corresponding measures according to the different error messages. Well, it is also a good choice to simply apply third party tool to clean hard drive or format it in Windows 10/8/7.