Sign in to follow this  
Followers 0
Luigi

Unknow theme, need sugestion. HDDSerial from VirtualMachine.

2 posts in this topic

Hi, I am not create the fuctions below, only rewrite and the original location was maintained...

a] this function with 'select * from win32' is a new thing for me, what's name from this content? I want study more about this. Someone can sugest more about for me please.

b] in the function _HddSerial() work fine, and return the serial from a real HD, but I work with virtual machines too... and this function crash in VM. I don't know to write a condition for _HddSerial for VM's hard disk drive. Ahhh... The fuction crash if have more than one hdd.

Best regards. 8D

Detefon

; http://www.autoitscript.com/forum/topic/69501-drivegetserial-report-different-hdd-serial-no/page__hl__drive++serial
; http://www.codeproject.com/KB/cs/hard_disk_serialno.aspx
ConsoleWrite("Hard Disk Drive Serial[" & _HddSerial() & "]" & @LF)
ConsoleWrite("MacAdress[" & _Mac() & "]" & @LF)
Func _HddSerial()
; Adapted function
; 06/09/2011
; http://www.autoitscript.com/forum/topic/69501-drivegetserial-report-different-hdd-serial-no/page__hl__drive++serial
; http://www.codeproject.com/KB/cs/hard_disk_serialno.aspx
Local $objWMIService = ObjGet("winmgmts:\\localhost\root\CIMV2")
Local $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_DiskDrive", "WQL", 0x10 + 0x20)
If IsObj($colItems) then
  For $objItem In $colItems
   If StringInStr($objItem.Name,"\\.\PHYSICALDRIVE0")>=0 Then Return $objItem.SerialNumber
  Next
Else
  Return False
Endif
EndFunc
Func _Mac()
; Adapted function
; 06/09/2011
; http://www.autoitscript.com/forum/topic/93183-wmi-ip-data/
Local $objWMIService = ObjGet("winmgmts:\\localhost\root\CIMV2")
Local $colAdapters = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True")
If IsObj($colAdapters) then
  For $objAdapter In $colAdapters
   Return $objAdapter.MACAddress
  Next
Else
  Return False
Endif
EndFunc

Visit my repository

Share this post


Link to post
Share on other sites



I try rewrite this... is good?

Func _HddSerial()
; Adapted function
; 06/09/2011
; http://www.autoitscript.com/forum/topic/69501-drivegetserial-report-different-hdd-serial-no/page__hl__drive++serial
; http://www.codeproject.com/KB/cs/hard_disk_serialno.aspx
Local $objWMIService = ObjGet("winmgmts:\\localhost\root\CIMV2")
Local $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_DiskDrive", "WQL", 0x10 + 0x20)
Local $Counter = 0
Local $Result = ""
If IsObj($colItems) then
  For $objItem In $colItems
   If StringInStr($objItem.Name,"\\.\PHYSICALDRIVE" & $Counter)>=0 Then $Result &= $Counter & ":" & $objItem.SerialNumber
   $Counter +=1
  Next
  Return StringMid($Result,1,StringLen($Result)-1)
Else
  Return False
Endif
EndFunc

Visit my repository

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0