quasimodo

DriveGet.... including off-line drives

3 posts in this topic

Hi,

I'm looking for a function which return ALL (windows)drive numbers and serial numbers inluding the drives which are currently set offline (e.g. by diskpart). The only "Drive..." function accepting a drive number seems to be "DriveGetType".  Even only getting the serial number of an off-line disk would help too.

 

 

Share this post


Link to post
Share on other sites



$wmic = Run(@ComSpec & " /c" & @ComSpec & ' /c ' & "wmic diskdrive get serialnumber","", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
    Local $Output = ""
    While 1
        $Output &= StdoutRead($wmic)
        If @error Then ExitLoop
    Wend
    $sOutput=StringSplit($Output,@CR)
    for $a=1 to $sOutput[0]
            ConsoleWrite($sOutput[$a])
    next
    
    $vol = Run(@ComSpec & " /c" & @ComSpec & ' /c ' & "vol C:","", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
    Local $Output = ""
    While 1
        $Output &= StdoutRead($vol)
        If @error Then ExitLoop
    Wend
    $sOutput=StringSplit($Output,@CR)
    for $a=1 to $sOutput[0]
            ConsoleWrite($sOutput[$a])
    next

 

2 people like this

Share this post


Link to post
Share on other sites

@rootx

Thank you very much for this script. Seems that wmic opens a quit new view inside windows!

But there is a secret left: Why do you insert "@ComSpec" a second time into the run() command? It's working without it, too.

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