Belini Posted July 16, 2018 Posted July 16, 2018 (edited) I am having problems getting the serial from the pendrive on windows 7 64 bit, can anyone help? #include <Array.au3> #include <String.au3> getUsbSerial() Func getUsbSerial() Local $letter[1], $disk[1], $aArray[1][2], $i, $informat = '', $espaco = '' Local $objWMIService = ObjGet("winmgmts:{impersonationLevel=Impersonate}!\\.\root\cimv2") If IsObj($objWMIService) Then Local $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_DiskDrive", "WQL", 0x10 + 0x20) For $objitem In $colItems If $objitem.interfacetype = "USB" And $objitem.DeviceId Then For $partition In $objWMIService.ExecQuery("ASSOCIATORS OF {Win32_DiskDrive.DeviceID='" & $objitem.DeviceId & "'} WHERE AssocClass = Win32_DiskDriveToDiskPartition") Next If (IsObj($partition) And $partition.DeviceId) Then For $loDisk In $objWMIService.ExecQuery("ASSOCIATORS OF {Win32_DiskPartition.DeviceID='" & $partition.DeviceId & "'} WHERE AssocClass = Win32_LogicalDiskToPartition") Next $aRegExSer = StringRegExp($objitem.pnpdeviceid, "\x5C([0-9a-fxA-FX]+)&", 3) If IsArray($aRegExSer) Then $i += 1 $informat = "" _ArrayAdd($disk, $aRegExSer[0]) _ArrayAdd($letter, $loDisk.DeviceId) $espaco = DriveSpaceTotal($letter[$i]) / 1024 $espaco = StringMid($espaco, 1, StringInStr($espaco, ".", 2, 1) + 2) & " GB" MsgBox('', '', "Letter = " & $letter[$i] & @CRLF & "Size = " & $espaco & @CRLF & "Serial = " & _ $disk[$i] & @CRLF & "Name = " & $objitem.Caption & @CRLF & "ID = " & $objitem.PNPDeviceID) EndIf EndIf EndIf Next EndIf EndFunc ;==>getUsbSerial Edited July 19, 2018 by Belini My Codes: Virtual Key Code UDF: http://www.autoitscript.com/forum/topic/138246-virtual-key-code-udf/ GuiSplashTextOn.au3: http://www.autoitscript.com/forum/topic/143542-guisplashtexton-udf/ Menu versions of Autoit: http://www.autoitscript.com/forum/topic/137435-menu-versions-of-autoit/#entry962011 Selects first folder of letters: ]http://www.autoitscript.com/forum/topic/144780-select-folders-by-letter/#entry1021708/spoiler] List files and folders with long addresses.: http://www.autoitscript.com/forum/topic/144910-list-files-and-folders-with-long-addresses/#entry102 2926 Program JUKEBOX made in Autoit:some functions:http://www.youtube.com/watch?v=WJ2tC2fD5Qs Navigation to search:http://www.youtube.com/watch?v=lblwOFIbgtQ
Danyfirex Posted July 16, 2018 Posted July 16, 2018 I think the device has not Unique ID so It's generate by the system. check here: It says: Note: If the second character of the unique instance ID is a '&', then the ID was generated by the system, as the device did not have a serial number. Saludos Belini and Earthshine 2 Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut
Belini Posted July 19, 2018 Author Posted July 19, 2018 Actually the pendrive had no serial, thanks for the tip! My Codes: Virtual Key Code UDF: http://www.autoitscript.com/forum/topic/138246-virtual-key-code-udf/ GuiSplashTextOn.au3: http://www.autoitscript.com/forum/topic/143542-guisplashtexton-udf/ Menu versions of Autoit: http://www.autoitscript.com/forum/topic/137435-menu-versions-of-autoit/#entry962011 Selects first folder of letters: ]http://www.autoitscript.com/forum/topic/144780-select-folders-by-letter/#entry1021708/spoiler] List files and folders with long addresses.: http://www.autoitscript.com/forum/topic/144910-list-files-and-folders-with-long-addresses/#entry102 2926 Program JUKEBOX made in Autoit:some functions:http://www.youtube.com/watch?v=WJ2tC2fD5Qs Navigation to search:http://www.youtube.com/watch?v=lblwOFIbgtQ
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now