"Overview: Encountered an error while partitioning the disk, access denied."

Some users reported that the disk cleanup operation fails midway when they try to clean up a USB flash drive from Command Prompt with Diskpart, due to an error message:

"Error encountered while partitioning the disk: Access denied.
Please refer to the system event log for more information."

When you check the System Event Log, you might see an error message such as: The device, \?\GLOBALROOT\Device\HarddiskVolume5, cannot be opened. Error code: 5@020A0019. This indicates that the storage device is considered blocked (or write-protected) and requires authorization.

Disk partition error

"Error Encountered in Disk Management, Access Denied - 3 Solutions"

To assist you in resolving the error message, we have provided three solutions below. You can utilize built-in tools or third-party utilities to address this issue. Choose the most suitable solution for your needs and follow the instructions accordingly.

1. Run Command Prompt as Administrator

This approach works with removable drives that require authorization. First, open a Command Prompt as an administrator:

Step 1: Click "Start," then click "All Programs," and then click "Accessories."
Step 2: Right-click "Command Prompt," and then select "Run as administrator."
Step 3: If you see a User Account Control dialog box, make sure the action it displays is what you want to do, and then click "Continue."

Run DiskPart again, and see if you still get Access is denied with the error.

There are two ways to help fix this problem, and they should be shared with others who need them.

Sorry, the content you provided is " ", which is a space character. It doesn't have a direct corresponding translation in Chinese. If you need a translation for specific English content, please provide more information.

2. Remove Write Protection from Hard Disk, USB Flash Drive or Memory Card

As mentioned above, you may also receive the “Diskpart encountered an error: Access is denied” error if your storage device is write protected. Here are the detailed steps to solve the "disk is write protected" issue.

1. Open the Start menu and click "Run"
2. Type regedit in the box
3. Navigate to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\StorageDevicePolicies
4. Then, double-click the "WriteProtect" key and change its value to 0.

Registry Replace - Write Protect Removal Tool

If you don't consider yourself a power user, and are not comfortable with the command line, don't worry – there are graphical solutions that can help you unprotect your hard drive, USB drive, or even an SD card.

CleanGenius is a tool that can help you fix such issues on your disk, without having to use the command line.

This is a simple and easy-to-understand guide on how to use this tool to address your issues:

Step 1: Download and install CleanGenius (free) on your computer.

Step 2: Run CleanGenius on your computer, and choose Optimize and Write Protection mode.

Write protection prohibited

Step 3: Select the write-protected device and click Disable to remove the protection.

Disable write protection on the storage device.

If the regedit path can't be found, we have one final trick up our sleeve.

3. Download a third-party formatting tool to resolve the "Access denied" issue with the disk partition.

Why would you bother using the Disk Management utility via Command Prompt to format a disk storage drive or a removable storage media? It's tricky and not an ideal solution for regular Windows users. The reasons are pretty obvious – Diskpart errors, like Access is denied, Incorrect function, and others, can drive you crazy once they pop up.

Thus, looking for an alternative to Diskpart should be the best solution when you can't format a disk, perform a clean install, or create partitions. tools Partition Master Free is an ideal alternative that offers all Diskpart features for home and office users. Here are some of its features:

    • Format disk partitions with just a few clicks.
    • Allow users to better organize their hard drive for improved system performance.
    • Migrate the operating system to an SSD for faster Windows boot and operation.
    • Convert between MBR and GPT disk styles, as well as primary and logical partitions, without data loss.

Download a free partition management tool, and use it to format the partition on your Windows computer according to the instructions.

Applies to: Windows 10, 8.1, 8, 7, XP, and Vista

Step 1. Launch AOMEI Partition Assistant, right-click the partition on the external hard drive/USB/SD card you want to format and choose "Format".

Format External Hard Drive/USB/SD Card - 1

Step 2: Specify a new partition label, file system (NTFS/FAT32/EXT2/EXT3/EXT4/exFAT), and cluster size for the selected disk partition, then click “OK”.

Format External Hard Drive/USB/SD Card - 2

<Step 3> Click Yes in the warning dialog box to continue.

Format External Hard Drive/USB/SD Card - 3

Step 4. Click on the 'Execute 1 Task' button on the top left to review the changes, and then click 'Apply' to start formatting the external hard drive/USB/SD card.

Format External Hard Drive/USB/SD Card - 4

Conclusions

Diskpart is a utility that aids in managing disks on your computer. However, it can encounter an error stating "diskpart encountered an error: Access is denied." This issue might arise due to write protection or the lack of administrative privileges to run the Command Prompt. Both reasons can make the disk inaccessible to diskpart, displaying it as blocked or unauthorized.

This article introduces methods to quickly resolve the "Access denied" error in Diskpart. You can fix this issue by running the Command Prompt with administrator privileges or disabling write protection through Diskpart or the Registry Editor.