How to get the drive letter of a Volume using command prompt

Using windows command line tools i want to get the drive letter of a volume, by specifying its volume number.

For example i have a HDD with 2 volumes: Volume-0 and Volume-1

I want to set a Variable say 'Letter'=<Drive Letter> such as

SET Letter=<Command> <Volume Number>

Is there any command which can do this for me...

Thanks...


March 12th, 2015 4:30pm

Hi,

You can use the diskpart tool to assign a drive letter to the drive by specifying the volume's number.

1.Open Command Prompt.

2.Type:diskpart

3.At the DISKPART prompt, type:list volume
Make note of the number of the simple volume whose drive letter you want to assign, change, or remove.

4.At the DISKPART prompt, type:select volume n
Select the volume, where n is the volume's number, whose drive letter you want to assign, change, or remove.

5.At the DISKPART prompt, type one of the following:assign letter=L
Where L is the drive letter you want to assign or change.

For more detailed information, you could refer to the article below:

Assign, change, or remove a drive letter
https://technet.microsoft.com/en-us/library/cc757491(v=ws.10).aspx

Best Regards,

Mandy 
Free Windows Admin Tool Kit Click here and download it now
March 16th, 2015 2:59am

Thanks for the reply.

But sir i do not want to assign drive letter. Drive letter is already assigned like Volume-0=C, Volume-1=D

i just want to set an environment variable which is equal to Volume-1's drive letter. that is C

Because if the harddisk drive is portable then it is not possible the Volume-1 is assigned with same letter among different computers. So, i want to confirm what drive letters is assigned, before executing a batch file.

March 23rd, 2015 9:09am

Hi,

It seems that you need to use script to achieve this. Please refer to the thread below to see if it helps.

Batch script to detect drive letter of a USB flash drive.
https://social.technet.microsoft.com/Forums/scriptcenter/en-US/bc64aef0-e4c0-43fb-ad20-49951f3abde4/batch-script-to-detect-drive-letter-of-a-usb-flash-drive?forum=ITCG

If the thread is not helpful, you need to ask for help from script forum for better and accurate answer.

https://social.technet.microsoft.com/Forums/scriptcenter/en-US/home?forum=ITCG

Best Regards,

Mandy
Free Windows Admin Tool Kit Click here and download it now
March 26th, 2015 3:23am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics