batch-filesolid-state-drive

How I can know if the disk is a SSD?


I need to create a T volume, T is created, but I also need a new U volume if the disk is a ssd, how i can do it ? What is the batch command to know if I'm a SSD ?

[...]
set /a VOL_SIZE= %MINSIZE_MB% /2
set VOL_TYPE=simple
if %NDISK% GTR 1 set VOL_TYPE=stripe

echo create volume %VOL_TYPE% size=%VOL_SIZE% disk=%DISKLIST%   >>%CMD_FILE%
echo Format fs=NTFS quick                                       >>%CMD_FILE%
echo assign letter=T                                            >>%CMD_FILE%


::if I'm not a SSD goto :noSSD

echo create volume %VOL_TYPE% disk=%DISKLIST%                   >>%CMD_FILE%
echo Format fs=NTFS quick                                       >>%CMD_FILE%
echo assign letter=U                                            >>%CMD_FILE%

:noSSD
[...]

best regard.


Solution

  • In cmd you can type following command which invokes PowerShell and passes it command which will return "SSD" if disk is of that type:

    powershell.exe "(get-physicaldisk).MediaType"
    

    Per phuclv's advice, simplest way to use return value of this command in batch file would be:

    powershell.exe "exit ((get-physicaldisk).MediaType) -ne 'SSD'" && echo SSD
    

    Statement explanation, when SSD is present: