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.
As an alternative to using powershell, you could also try via wmic.
Open a Command Prompt window, paste the following line, and press ENTER
For /F Tokens^=6Delims^=^" %G In ('^""%SystemRoot%\System32\wbem\WMIC.exe" /NameSpace:\\root\Microsoft\Windows\Storage Path MSFT_PhysicalDisk Where "MediaType='4' And SpindleSpeed='0'" Get Model /Format:MOF 2^>NUL^"')Do @Echo %G is an SSD
This accesses the same information as PowerShell's Get-PhysicalDisk
. It first checks the MediaType
property. There are three possible values returned for that property, 0
(Unspecified); 3
(HDD); and 4
(SSD). For additional safety, I check that there is a spindle speed of 0
as there are no moving parts in an SSD, and return any model name which passes both checks.
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:
((get-physicaldisk).MediaType)
- evaluates to 'SSD''SSD' -ne SSD'
- evaluates to False (-ne is not-equal operator)exit
with logical false (False) - makes PowerShell exit without setting CMD's %ERRORLEVEL% to non-zero&&
- is CMD operator that executes second command when first command is successful (when %ERRORLEVEL% is zero)If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With