how can i detect drive letter of flash drive?

November 10, 2011 at 22:49:12
Specs: Windows 7
how can i detect usb drive letter in cmd???..

See More: how can i detect drive letter of flash drive?

Report •

November 11, 2011 at 02:34:01

Option Explicit
Dim objWMIService, objItem, colItems, strComputer
Dim strDriveType, strDiskSize
On Error Resume Next
strComputer = "."

Set objWMIService = GetObject _
("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery _
("Select * from Win32_LogicalDisk")

For Each objItem in colItems
Select Case objItem.DriveType
Case 1 strDriveType = "Drive could not be determined."
Case 2 strDriveType = "Removable Drive"
Case 3 strDriveType = "Local hard disk."
Case 4 strDriveType = "Network disk."
Case 5 strDriveType = "Compact disk (CD)"
Case 6 strDriveType = "RAM disk."
Case Else strDriveType = "Drive type Problem."
End Select

If objItem.DriveType =2 Then
Wscript.Echo objItem.Name

End If


Save this as C:\something.vbs

now from cmd call this
C:> something.vbs

It will return the drive letter of USB drive

What is Life ? A Question

Report •
Related Solutions

Ask Question