Run diskpart clean twice

When trying to clear a USB memory stick with diskpart I encountered this error:

DISKPART> clean

DiskPart has encountered an error: Access is denied.
See the System Event Log for more information.

 

The System event log contained this error from VDS Basic Provider:

Cannot zero sectors on disk \\?\PhysicalDrive2. Error code: 5@0101000F

 

The problem was solved simply by running clean again:

DISKPART> clean

DiskPart succeeded in cleaning the disk.

 

After that a partition could be created and formatted.

 

Warning: Always be very careful when using diskpart.

In order to avoid data loss make sure to list disks, select the correct disk and list disks again before running diskpart clean.