2

I need to write a little script for a specific HDD.
I use the following command to detect the HDD by size:

 C:\>wmic logicaldisk get size,freespace,caption | find "750153363456"

 E:       27996512256  750153363456

Now I need to store the drive-letter from that output (in this case E:) into a variable. How can I do that?

1

why dont you use the serialnumber to find your drive ? One possible solution saving the result of wmic in a file :

REM replace D4B12CD with your drive serialnumber

wmic logicaldisk get caption,volumeserialnumber |findstr D4B12CD > c:\temp\Hdd.txt 
for /f %%i in (c:\temp\hdd.txt) do set mydrive=%%i

REM now mydrive contains the letter of your drive
echo %mydrive%
1
  • I think that if you don't want to do a serialnumber search, you could at least store the value in a text file as demonstrated here. – Wally Jan 14 '14 at 15:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.