top of page
Search
reubentrueheart247

Read hard disk serial number vb net: Comparing different approaches and performance



Current status of the object. Various operational and nonoperational statuses can be defined. Operational statuses include: "OK", "Degraded", and "Pred Fail" (an element, such as a SMART-enabled hard disk drive, may be functioning properly but predicting a failure in the near future). Nonoperational statuses include: "Error", "Starting", "Stopping", and "Service". The latter, "Service", could apply during mirror-resilvering of a disk, reload of a user permissions list, or other administrative work. Not all such work is online, yet the managed element is neither "OK" nor in one of the other states.


A physical disk drive is the cornerstone of any storage management system. However, after a physical disk drive has been installed, neither users nor system administrators typically deal with the hardware directly. Instead, both users and system administrators interact with the logical drives that have been created on the disk.




read hard disk serial number vb net




A logical drive is a subdivision of a partition that has been assigned its own drive letter. (It is possible to have a partition that has not been assigned a drive letter.) When you talk about drive C or drive D, you are referring to a logical drive rather than to a physical disk drive. Likewise, when you save a document to drive E, you are saving it to the logical drive. Physical disks compose the hardware that makes up a drive, including such components as heads, sectors, and cylinders. Logical drives, by contrast, have properties such as disk space, available disk space, and drive letters.


Enterprise scripting often involves configuring hardware and software on remote computers; in turn, this requires you to know, in advance, the type of disk drives installed on a computer. For example, a script that installs an application on drive E works only if drive E is a hard disk. If drive E happens to represent a floppy disk or a CD-ROM drive, the script fails. The following code identifies the drives and drive types installed on a computer


What is a hard drive serial number? Refers to the identity as a hard drive, but sometimes it is found that the computer hard drive serial number of the colleague is duplicated. So the hard drive identification we can try to test the ID, this how to get the following explanation.


According the documentation on MSDN, Win32_Volume - Serial number is just the serial number of the Volume whereas the Win32_DiskDrive - Serial number is the manufacturer serial number of the disk drive. So the question is which serial number do you want?


This doesn't really doesn't address the underlying issue shown in the question: WMI is returning acorrupt serial number. Mark is getting the serial number encoded as hexadecimal digit pairs which represent the ASCII characters of the actual serial number. This does not match the documented behavior.


Not a bug. It is the way the vendor inserts the serial number into the device. The serial number has been inserted as a hex string. Thisis also the way SNMP serial numvers are meant to work. WMI and CIM make no attempt to convert this data. That is up to the end user. YOu must know how the vendor inserts this.


Thanks, your reply is actually very helpful. I think the key part of my post you may have missed was where I mention theintermittent results we see. Same vendor, same drive, but the serial number comes back in different forms for thesame WMI property. That is what has led us to conclude that WMI isn't merely passing that data back as-is [we would actually prefer that]. We're just not sure if it's attempting to fix the values but after a delay, or if it's switching which driver calls it uses, or if there are just race conditions inherent in the design of the system.


Anyway, for now let's just talk about the prevalence of hexadecimal format, and the predictable [non-intermittent] format changes I've seen. Here's a simple query run on my Windows 7 system. The blue window is running as an elevated account, the black window is running as a normal user account. Note that none of the drive serial numbers are in hexadecimal. Also note that the query returns the values in different forms [big-endian or little-endian ASCII] depending on which user does the query. To make things more unpredictable, the third drive's serial number remains the same [it's a CD drive], so we can't make reliable assumptions about how to "fix" the serial numbers. This particular behavior is all new with Vista; our code had worked as expected on Windows XP.


jrv, I hate to break it to you, but HD serial numbers have never been represented as hex-encoded ASCII strings. It's just the way Windows shows them. Why would they be hex? Take a unit from your shelf or ask someone to hand it over to you and check the S/N imprinted on the label. Is it hex-encoded? I'm sure it's not. And so it is no t flashed as such in device's ROM. Grab a live CD with Linux, if you want, launch it and run `hdparm -I /dev/ grep Serial' from terminal. I did that for my SSD. Here's what the result read: OCZ-E84E5605IJTH4698 and here's what Windows gives:434f2d5a38454534363535304a49485436343839 ...yeah.Of course, you might think that Linux processes the original data to provide that clean string. It (almost) does not. Want a proof? Thankfully, unlike with Windows, we can check Linux source code,here is the link to ATA driver core, check it out.The only processing that takes place on Linux is swapping every two bytes with each other. This is an important part because it explains why hex-pairs are un-flipped on Windows so please bare with me. Drives send serial number and other information in response to ATAPI command IDENTIFY DEVICE. The response is being sent in 16-bit words. This doesn't make sense today when most drives use serial communication, but it works that way to maintain backwards compatibility with IDE (PATA drives) which were indeed using 16-bit data bus. ATAPI specification enforces the drive to encode all ASCII strings on 2-byte words using big-endian notation, so when you see such chunk of memory on little-endian machine (every Windows is LE, I think) it appears that subsequent pairs of bytes have been flipped.Now what Windows does apparently, is to take the memory as it was received from the device and encode it to hex. I don't know the reasoning behind it. This method probably made some sense in the old days and was preserved until today for compatibility reasons. I wouldn't have troubles with it if the results were consistent across all versions of Windows but, clearly, they are not.When you run the following command:


on Windows 7 x64 (winver: 6.1, build 7601) using admin account, the serial number will be hex-encoded and flipped. If you start powershell with elevated permissions, it will be correct (ASCII and not-flipped). Mind you, I'm talking here about the same account that has admin privileges. The only difference is that you start powershell a) normally, b) using "run as administrator". Further more, Model property returned by the query above is empty regardless of what method you use.


I haven't encountered this problem with Win32_DiskDrive, though. Limited users, admins, elevated or not, it always returns SerialNumber in hex-encoded and flipped form. I guess that's something. But the property isn't available on Windows XP so you have to diverge your script depending on host OS.Here's another quirk, BTW. On Windows 7 Win32_DiskDrive.Model property is suffixed with " device". So if your drive model is "OCZ-AGILITY3" (as returned by ATAPI), the Model property will be "OCZ-AGILITY3 ATA device". Windows XP, however, reports it without extras. Lovely, isn't it?So btj-agilent is correct all the way:a) Windows returns drive serial number, which is not a real serial number,b) the number can differ depending on the OS (which was a topic of a couple of bug reports on Microsoft Connect).The flipped S/N are caused by buggy WMI, not encoding problems. (BTW, jrv, how on earth can the difference between ANSI and Unicode encoding be responsible for swapping letters in string? Care to explain?)To the OP and anyone who wants to use WMI to get HD properties:If you can, avoid WMI when accessing those information. Especially if some vital functionality depends on it. WMI just appears to be broken and you cannot depend on it giving you concise results. Use IOCTLs in an executable tool and wrap it with your script instead. If you have to use PowerShell all the way (for example when you need to run the command remotely on domain nodes) take into account the points above. The subject of WMI returning bad serial numbers for accounts with different access rights was reported to Microsoft in 2010. Apparently it hasn't been fully resolved since.


Hello guys,I need to find out what is my drive's serial number under win XP.I know that there are one serial number from manufacturer (real hard drive) and serial numbers generated by windows.I know that if disk is partitioned into more partitions that each partition will have unique serial number called Volume serial number.That number can be obtained by typing dir into cmd prompt.Is there any other way to find out real serial number without need to open case.


For XP, navigate: start>control panel>system, select the 'hardware' tab>device manager, expand 'disk drives' then right click on the hdd in question. select properties then click the 'details' tab. from the drop down box select 'hardware ids' and bingo.....info should include brand name manufacturer,interface type,model no,serial etc, all you should need!! 2ff7e9595c


0 views0 comments

Recent Posts

See All

Comments


bottom of page