Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

add %@drivemediatype and %@drivebustype variable functions

Sep
70
1
In Powershell you can do the command
Get-PhysicalDisk | select Friendlyname, BusType, MediaType

To see the bustype and mediatype for disks, but there isn't an easy way to then connect this to a specific drive. It would be nice to know if drives returned from %@drivetypeex of type 3 were HDD, SSD, and if SSD if they were NVME. Some things happen so fast on NVME drives that they become CPU limitted so it would be nice to be able to check for this.
 
@mdlawler if you are referring to dtype.btm,
the source code for dtype.btm is here.

Joe
Here is a modified version to give the bus type

@echo off
setlocal
if %# == 0 (echo Usage: DTYPE.BTM drive_letter[...] & quit)
:: DriveLetter is the ASCII code of an uppercase letter; e.g., the c drive is 67
set letter=%@ascii[%@upper[%@instr[0,1,%1]]]
set DiskNumber=%@wmi[root\Microsoft\Windows\Storage,"select DiskNumber from MSFT_Partition where DriveLetter=%letter"]
if "%DiskNumber" == "" ( echoerr No such disk & quit )
set MediaType=%@wmi[root\Microsoft\Windows\Storage,"select MediaType from MSFT_PhysicalDisk where DeviceId=%DiskNumber"]
if "MediaType" == "" (echoerr Unknown error & quit)
set BusType=%@wmi[root\Microsoft\Windows\Storage,"select BusType from MSFT_PhysicalDisk where DeviceId=%DiskNumber"]
if "BusType" == "" (echoerr Unknown error & quit)
switch %MediaType
case 0
echos UNSPECIFIED ``
case 3
echos HHD ``
case 4
echos SSD ``
case 5
echos SCM ``
default
echos UNKNOWN ``
endswitch
switch %BusType
case 0
echo UNSPECIFIED
case 1
echo SCSI
case 2
echo ATAPI
case 3
echo ATA
case 4
echo IEEE 1394
case 5
echo SSA
case 6
echo Fibre Channel
case 7
echo USB
case 8
echo RAID
case 9
echo iSCSI
case 10
echo Serial Attached SCSI (SAS)
case 11
echo Serial ATA (SATA)
case 12
echo Secure Digital (SD)
case 13
echo Multimedia Card (MMC)
case 17
echo NVME
default
echo UNKNOWN
endswitch
endlocal
 
Code:
@echo off
setlocal
    if %# == 0 (echo Usage: DTYPE.BTM drive_letter[...] & quit)
    :: DriveLetter is the ASCII code of an uppercase letter; e.g., the c drive is 67
    set letter=%@ascii[%@upper[%@instr[0,1,%1]]]
    set DiskNumber=%@wmi[root\Microsoft\Windows\Storage,"select DiskNumber from MSFT_Partition where DriveLetter=%letter"]
    if "%DiskNumber" == "" ( echoerr No such disk & quit )
    set MediaType=%@wmi[root\Microsoft\Windows\Storage,"select MediaType from MSFT_PhysicalDisk where DeviceId=%DiskNumber"]
    if "MediaType" == "" (echoerr Unknown error & quit)
    set BusType=%@wmi[root\Microsoft\Windows\Storage,"select BusType from MSFT_PhysicalDisk where DeviceId=%DiskNumber"]
    if "BusType" == "" (echoerr Unknown error & quit)
    switch %MediaType
        case 0
            echos UNSPECIFIED ``
        case 3
          echos HHD ``
        case 4
          echos SSD ``
        case 5
        echos SCM ``
            default
        echos UNKNOWN ``
    endswitch
  switch %BusType
        case 0
          echo UNSPECIFIED
        case 1
            echo SCSI
        case 2
            echo ATAPI
        case 3
          echo ATA
        case 4
          echo IEEE 1394
        case 5
          echo SSA
        case 6
            echo Fibre Channel
        case 7
            echo USB
        case 8
            echo RAID
        case 9
            echo iSCSI
        case 10
            echo Serial Attached SCSI (SAS)
        case 11
            echo Serial ATA (SATA)
        case 12
          echo Secure Digital (SD)
        case 13
            echo Multimedia Card (MMC)
        case 17
            echo NVME
        default
            echo UNKNOWN
    endswitch
endlocal
 
Back
Top
[FOX] Ultimate Translator
Translate