Is there a way to make DISKPART dynamic?


We have a DISKPART script that singles out drives and basically formats and assigns a drive letter to the particular drive we're looking at.

This is all VERY static configurations, in that we target DriveID 0, 1, 2 etc.  Any time we need to change something, we need to update the script.

Is there a way to have DISKPART just go ahead and rip through all available drives and assign drive letters in sequence?

I've tried a VbScript to accomplish this, but if the obj.Drives.IsReady is false, there's not much I can do with the drive.

Would anybody happen to have any information on this sort of stuff?  Basically, I'd like to take all physical drives that aren't currently assigned a drive letter - and assign them the next available one on the system.  Including drives that are "offline", "not ready" or any other combination possible.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

According to the docs (, when using the ASSIGN command, "If no drive letter or mount point is specified, then the next available drive letter is assigned."
usslindstromAuthor Commented:
Ah.  Thank you for that.  I didn't realize.

That will solve the issue of having to map them statically, but would you happen to know if it's possible to give DISKPART logic on the first half, where it grabs Drive0,1,2 etc. if they're not already assigned drive letters?

Well, since you are comfortable with scripting, how about having a script that contains simply "LIST DISK" and pipe the output to a file?  You could use the script to find the disks, and with that info, create a second script to "SELECT DISK x" and "DETAIL DISK" for each of the disks and pipe that to a file.

With that, you should have all the info you need to write the "real" script that does what you want.

A little clunky, but it should work.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
usslindstromAuthor Commented:

That's a very nice idea!  - I hadn't thought of piping to txt then parsing through VB.

I'll see what I can come up with.  Thanks for the ideas.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows XP

From novice to tech pro — start learning today.