Get HDD Serial Number
-
Hi, I wanna to get hard disk serial number i m using this code it work well in my pc but in client pc it doesn't give hdd serial no i don't know that given number belogs to which physical media?
Dim mgmtobj As New ManagementObject Dim searcher As ManagementObjectSearcher searcher = New ManagementObjectSearcher("SELECT * FROM Win32_PhysicalMedia") For Each mgmtobj In searcher.Get If mgmtobj("SerialNumber") = Nothing Then serial = "" Else serial = mgmtobj("SerialNumber").ToString.Trim End If Next
Really its very urgent for me now ThanksThe Great Pleasure In Doing That Things That Other People Say U Can't By Doing This U Can Shut Their Mouth
-
Hi, I wanna to get hard disk serial number i m using this code it work well in my pc but in client pc it doesn't give hdd serial no i don't know that given number belogs to which physical media?
Dim mgmtobj As New ManagementObject Dim searcher As ManagementObjectSearcher searcher = New ManagementObjectSearcher("SELECT * FROM Win32_PhysicalMedia") For Each mgmtobj In searcher.Get If mgmtobj("SerialNumber") = Nothing Then serial = "" Else serial = mgmtobj("SerialNumber").ToString.Trim End If Next
Really its very urgent for me now ThanksThe Great Pleasure In Doing That Things That Other People Say U Can't By Doing This U Can Shut Their Mouth
Please read the forum guidelines. Using 'urgent' in your message (or title) is frowned upon and my get you ignored completely.
New feature! Scroll down to see CP offenders! Upcoming blogs: "My cats are evil." http://craptasticnation.blogspot.com/[^]
-
Hi, I wanna to get hard disk serial number i m using this code it work well in my pc but in client pc it doesn't give hdd serial no i don't know that given number belogs to which physical media?
Dim mgmtobj As New ManagementObject Dim searcher As ManagementObjectSearcher searcher = New ManagementObjectSearcher("SELECT * FROM Win32_PhysicalMedia") For Each mgmtobj In searcher.Get If mgmtobj("SerialNumber") = Nothing Then serial = "" Else serial = mgmtobj("SerialNumber").ToString.Trim End If Next
Really its very urgent for me now ThanksThe Great Pleasure In Doing That Things That Other People Say U Can't By Doing This U Can Shut Their Mouth
I have this code in my library for getting the HDD serial number. I know its not the best code - I cant remember where I got it from, but it does seem to work on the few machines I have tested it with:
Dim mobjSearcher As New ManagementObjectSearcher("SELECT \* FROM Win32\_LogicalDisk WHERE Name = 'C:'") For Each obj As ManagementObject In mobjSearcher.Get Return obj("VolumeSerialNumber").ToString Next Return "00000000000000"
Maybe it will work for you?
-
Hi, I wanna to get hard disk serial number i m using this code it work well in my pc but in client pc it doesn't give hdd serial no i don't know that given number belogs to which physical media?
Dim mgmtobj As New ManagementObject Dim searcher As ManagementObjectSearcher searcher = New ManagementObjectSearcher("SELECT * FROM Win32_PhysicalMedia") For Each mgmtobj In searcher.Get If mgmtobj("SerialNumber") = Nothing Then serial = "" Else serial = mgmtobj("SerialNumber").ToString.Trim End If Next
Really its very urgent for me now ThanksThe Great Pleasure In Doing That Things That Other People Say U Can't By Doing This U Can Shut Their Mouth
But - the obvious mistake you have made is... If you find more than one drive in your search, and the SECOND drive doesnt have a serial number (for whatever reason), you are clearing the serial number... Oops? Thats the problems with for...next loops setting variables.
-
Hi, I wanna to get hard disk serial number i m using this code it work well in my pc but in client pc it doesn't give hdd serial no i don't know that given number belogs to which physical media?
Dim mgmtobj As New ManagementObject Dim searcher As ManagementObjectSearcher searcher = New ManagementObjectSearcher("SELECT * FROM Win32_PhysicalMedia") For Each mgmtobj In searcher.Get If mgmtobj("SerialNumber") = Nothing Then serial = "" Else serial = mgmtobj("SerialNumber").ToString.Trim End If Next
Really its very urgent for me now ThanksThe Great Pleasure In Doing That Things That Other People Say U Can't By Doing This U Can Shut Their Mouth
First of all thanks to all for reply I know its not good to say "Urgent" but its really very very urgent for me so i had to wrote Thanks Jasey9 for your code but....
Return obj("VolumeSerialNumber").ToString
I have already tried it but it will return the volume number of a particular Drive like C: but after format the Pc it will change so i need only the serial number of hard disk Is there any way to varify that the number returned bysearcher = New ManagementObjectSearcher("SELECT * FROM Win32_PhysicalMedia")
is hard disk serial number,I need your guidance... ThanksThe Great Pleasure In Doing That Things That Other People Say U Can't By Doing This U Can Shut Their Mouth
-
Hi, I wanna to get hard disk serial number i m using this code it work well in my pc but in client pc it doesn't give hdd serial no i don't know that given number belogs to which physical media?
Dim mgmtobj As New ManagementObject Dim searcher As ManagementObjectSearcher searcher = New ManagementObjectSearcher("SELECT * FROM Win32_PhysicalMedia") For Each mgmtobj In searcher.Get If mgmtobj("SerialNumber") = Nothing Then serial = "" Else serial = mgmtobj("SerialNumber").ToString.Trim End If Next
Really its very urgent for me now ThanksThe Great Pleasure In Doing That Things That Other People Say U Can't By Doing This U Can Shut Their Mouth
hi What do you want to do with a HDD Serial number, for sure it changes when the HDD get formated. its not Stable, if you want this for Software protection thing, then i think you should go for Processor ID, that will never change. Thanks
Vuyiswa Maseko, Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding VB.NET/SQL7/2000/2005 http://vuyiswamb.007ihost.com http://Ecadre.007ihost.com vuyiswam@tshwane.gov.za