Reset readonly disk via Diskpart

Hi,

During development, we encountered a situation where a disk exposed to a W2K8 machine has the ‘Read-only’ attribute set. Since our software mounts this disk and writes to the file system we need the attribute clear.

To overcome, I used Diskpart commands:
SELECT DISK n
ATTRIBUTES DISK CLEAR READONLY

This seemed to work, however I wish to perform this operation in code and not call Diskpart. Can anyone tell me which IOCTL/API can be used for this end (preferably in user-mode, but kernel-mode can also be OK)?

I was looking into using IOCTL_DISK_RESET_SNAPSHOT_INFO which is used to preform a similar operation on VSS snapshots. Is this relevant?

Thanks.

>Can anyone tell me which IOCTL/API can be used for this end (preferably in >user-mode, but kernel-mode can also be OK)?
You could use VDS. The method ClearFlags of IVdsDisk would clear READ_ONLY attribute.

Igor Sharovar

Thanks Igor.
I will try this.