Sign in to follow this  
Followers 0
ModemJunki

List volume letters to your command window

1 post in this topic

I work in WinPE a bit.

Lots of times I find myself running diskpart just to "list volume" information in the command box, but all I really want is to see which letter was assigned to my "utility" disk (which is either a flash drive or a USB hard disk). Sometimes I do this from a DVD, and sometimes I've booted from a different flash or USB drive.

So I made a quick tool that types the information out to the DOS box. You don't have to compile for x64 in most cases, but a Windows PE image that is made x64 cannot support 32-bit executables...

I'm not even sure such a strange tool is useful to anyone else. :P

And for sure some types of mounted network drives may not show up (e.g., ClearCase volumes...)

#AutoIt3Wrapper_Compile_Both=y
#AutoIt3Wrapper_UseX64=y

#include <array.au3>

Global $aFixedInfo[1]
Global $aRamInfo[1]
Global $aRemoveableInfo[1]

$aCDROM = DriveGetDrive("CDROM")
$aREMOVABLE = DriveGetDrive("REMOVABLE")
$aFIXED = DriveGetDrive("FIXED")
$aNETWORK = DriveGetDrive("NETWORK")
$aRAMDISK = DriveGetDrive("RAMDISK")
$aUNKNOWN = DriveGetDrive("UNKNOWN")

If IsArray($aCDROM) Or IsArray($aREMOVABLE) Or IsArray($aFIXED) Or IsArray($aNETWORK) Or IsArray($aRAMDISK) Or IsArray($aRAMDISK) Or IsArray($aUNKNOWN) Then
    Send("Retrieving volume info.....")
    _doBreak()
Else
    Send("There was a problem retrieving volume letter info!")
EndIf

If IsArray($aUNKNOWN) Then
    $sUNKNOWN = StringTrimLeft(_ArrayToString($aUNKNOWN, " "), 2)
    Send("Unknown drive types: " & $sUNKNOWN)
    _doBreak()
EndIf

If IsArray($aNETWORK) Then
    $sNETWORK = StringTrimLeft(_ArrayToString($aNETWORK, " "), 2)
    Send("Network drives: " & $sNETWORK)
    _doBreak()
EndIf

If IsArray($aCDROM) Then
    $sCDROMList = StringTrimLeft(_ArrayToString($aCDROM, " "), 2)
    Send("CD drives: "& $sCDROMList)
    _doBreak()
EndIf

If IsArray($aRAMDISK) Then
    For $i = 1 To $aRAMDISK[0]
        $sLbl = DriveGetLabel($aRAMDISK[$i])
        _ArrayAdd($aRamInfo, $aRAMDISK[$i] & '(' & $sLbl & ')')
    Next
    $sRAMDISK = StringTrimLeft(_ArrayToString($aRamInfo, " "), 1)
    Send("RAM disks: " & $sRAMDISK)
    _doBreak()
EndIf

If IsArray($aREMOVABLE) Then
    For $i = 1 To $aREMOVABLE[0]
        $sLbl = DriveGetLabel($aREMOVABLE[$i])
        _ArrayAdd($aRemoveableInfo, $aREMOVABLE[$i] & '(' & $sLbl & ')')
    Next
    $sREMOVABLE = StringTrimLeft(_ArrayToString($aRemoveableInfo, " "), 1)
    Send("Removeable drives: " & $sREMOVABLE)
    _doBreak()

EndIf

If IsArray($aFIXED) Then
    For $i = 1 To $aFIXED[0]
        $sLbl = DriveGetLabel($aFIXED[$i])
        _ArrayAdd($aFixedInfo, $aFIXED[$i] & '(' & $sLbl & ')')
    Next
    $sFIXED = StringTrimLeft(_ArrayToString($aFixedInfo, " "), 1)
    Send("Fixed disks: "& $sFIXED)
    _doBreak()
EndIf

Func _doBreak()
    Send("{CTRLDOWN}")
    Send("C")
    Send("{CTRLUP}")
EndFunc   ;==>_doBreak

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  
Followers 0