Quantcast
Channel: Indigo Rose Software Forums - Forums
Viewing all articles
Browse latest Browse all 2105

Obtain the drive letters of physical devices forn USBSTORE

$
0
0
A long time ago I was looking for a way to get the drive letter of the connected physical device in the USBSTORE. I have the code but I would like to run this query inside the application in AutoPlay. Any ideas?
Code:
' ' GetLetterOFmyUSBstick.vbs
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
strPnPdevID = "USBSTOR\Disk&Ven_WD&Prod_3200BMV_External&Rev_1.7 5\57442D575831304139394C39303934&0"
strPnPdevID = Replace(strPnPdevID, "\", "\\")

Set colDiskDrives = objWMIService.ExecQuery ("SELECT * FROM Win32_DiskDrive where PNPDeviceID like '"& strPnPdevID &"' ")

For Each objDrive In colDiskDrives
Wscript.Echo "Physical Disk: " & objDrive.Caption & " -- " & objDrive.DeviceID
strDeviceID = Replace(objDrive.DeviceID, "\", "\\")
Set colPartitions = objWMIService.ExecQuery _
("ASSOCIATORS OF {Win32_DiskDrive.DeviceID=""" & _
strDeviceID & """} WHERE AssocClass = " & _
"Win32_DiskDriveToDiskPartition")

For Each objPartition In colPartitions
Wscript.Echo "Disk Partition: " & objPartition.DeviceID
Set colLogicalDisks = objWMIService.ExecQuery _
("ASSOCIATORS OF {Win32_DiskPartition.DeviceID=""" & _
objPartition.DeviceID & """} WHERE AssocClass = " & _
"Win32_LogicalDiskToPartition")

For Each objLogicalDisk In colLogicalDisks
Wscript.Echo "Logical Disk: " & objLogicalDisk.DeviceID
Next
Wscript.Echo
Next
Wscript.Echo
Next
I need to turn this code into something like:

Code:
function GetBios()
local strId = "";
local wmiServ = luacom.GetObject("winmgmts:\\\\.\\root\\CIMV2");
if wmiServ ~= nil then
-- BIOS DATA
local wmiQuery = wmiServ:ExecQuery("SELECT * FROM Win32_BIOS", "WQL", 16 + 32);
if wmiQuery then
local wmiEnum = luacom.GetEnumerator(wmiQuery);
local wmiItem = wmiEnum:Next();
while wmiItem do
strId = strId..VtoS(wmiItem:SerialNumber())..VtoS(wmiItem: Manufacturer());
wmiItem = wmiEnum:Next();
end
end
end
return strId;
end

Viewing all articles
Browse latest Browse all 2105

Trending Articles