Reputation: 433
I have a script I am running on my USB. I need it to return the disk Number of the USB for later use in running a command. Please Can Someone help me tried googling but I cant find what I am looking for.
Upvotes: 0
Views: 71
Reputation: 200273
You can obtain the information from the Win32_DiskDrive
WMI class:
Set wmi = GetObject("winmgmts://./root/cimv2")
qry = "SELECT * FROM Win32_DiskDrive WHERE InterfaceType = 'USB'"
For Each d In wmi.ExecQuery(qry)
WScript.Echo d.Index
Next
If you have more than one USB disk connected you need to provide additional filtering criteria, of course.
If you want to get the disk number by drive letter take a look at this answer.
Upvotes: 1