Jump to content
Sign in to follow this  

scan fixed drives avioding partitions

Recommended Posts

I'm writing a small script to backup my favorites etc, I am planning to scan for second hard disks or removable media and having the option to select any resulting drives as a backup destination.

here's an example...

$ddrive = DriveStatus ( "d:" )

If $ddrive="READY" then
$drivetype = DriveGetType( "d:\" )
If $drivetype="FIXED" then ??????

the problem is though, I want to aviod partitions on the primary hard disk which will get wiped when reinstalling my os, so in some cases D will be a partition, and not a good place to keep a backup.

is there any way to differentiate physical disks, ie... HD0,HD1 to avoid partitions?

Share this post

Link to post
Share on other sites

This will get you started.

$objWMIService = ObjGet("winmgmts:\\.\root\CIMV2")
$colItems = $objWMIService.ExecQuery ("SELECT * FROM Win32_LogicalDiskToPartition")
For $objItem in $colItems
    MsgBox(0,"",StringMid($objItem.Dependent,StringLen($objItem.Dependent)-2,1) & " drive is on " & _
                StringMid($objItem.Antecedent,StringInStr($objItem.Antecedent,"=")+2,7) & ".")

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...