0

I wanted to create a batch file that will enable or disable write protection. Basically, 2 batch files, one to enable and the other to disable write protection. I used to do it manually in CMD by using these commands.

Step 1: Start CMD In Administrater Mode

Step 2: Type Diskpart

Step 3: Type list volume

Step 4: Type select volume 5

Step 5: Type attributes volume set readonly OR attributes volume clear readonly

A batch file that does it will be much better but I have zero knowledge about that. I searched on the internet and managed to create a batch file that open up diskpart but couldn't go any further.

here's the code for that:

@ECHO OFF

Diskpart

PAUSE

Now, how do I make it to list volumes?

1 Answer 1

1

You can accomplish this by using diskpart scripts. You would call diskpart /s yourscript.txt. You would type your commands into the script file like you normally would manually.

Depending on your familiarity with PowerShell, you would get better control using PowerShell Get-Disk / Get-Partition

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.