I am trying to develop a batch file to run and remove the Hidden partitions in Windows 7, when trying to remove all partitions. Normally I do this line by line in the Command prompt windows, but was trying to figure out how to create a batch file to run and speed this process up..
Here are lines I type in the command prompt.
disk part
Rescan
List Disk
Select Disk 3
List Partition
Select Partition 3
Delete Partition Override
I have created a BAT file but can only get the first command to work.
Place your diskpart commands (the ones you type after typing
diskpart
) in a text file likescript.txt
and call diskpart with the following command.But be very careful that your commands are correct and well tested and don't call the batch file diskpart.
See here for more information: http://support.microsoft.com/kb/300415
So hey, I know I'm super late to the party, but I've been messing around with Diskpart and scripting, etc for some post-imaging stuff I want to do, and, though it's not a direct solution to your EXACT question, read through it anyways, and I bet you can kludge this into what you need to do: (Yes, it's very kludge-y. I don't care. It exists as ONE file, no external files necessary, and cleans up after itself.)
It is really very easy, and when i look at other answers i think "Why do it easy when it gets hard" :D
Okay, diskpart have his own CLI (command line interface) this is the reason, why you cannot wirte your commands via batch file. Now we only must lie to diskpart and emulate input to his CLI. We can do it this way:
And at the end the pipe redirect echo output, so it did not wirte to command line CLI but to diskpart CLI.
That is all!
I hit here while searching how to add comments to the diskpart script file. Later found that comments can be added using REM command.