VBScript – Return Drive Letter by Drive Label Name

email me

strComputer = "."

DriveLetter = ""

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery ("Select * From Win32_LogicalDisk")

For Each objItem in colItems

If objItem.VolumeName = "KINGSTON" then DriveLetter = objItem.DeviceID

Next

msgbox DriveLetter