Wmi Win32_diskdrive Serial Number
- Posted in:Admin
- 10/06/18
- 16


In Win32_DiskDrive there is also a SerialNumber, but now it is a string. Typically, it has leading hex 20s followed by other characters - here the same drive as above has. Is there a way to transform one of these Serial Numbers so as to be able in a script to get the. Aug 19, 2017 WMI Win32_PhysicalMedia SMART ID in Vista and 7 Permissions.NET Framework. With Win32_DiskDrive, I get the serial number on.
This may not do everything you asked for, is not thoroughly debugged, will not work on Windows 95 (and perhaps not on any Win9x OS), has not been thoroughly tested on Windows XP, etc. But it does work at least on systems where I've thoroughly tested it (Windows Vista and later), and seems to at least partially work on Windows XP (USB flash drives not tested). That doesn't mean it will work on all Vista and later systems, since hard drive manufacturers do some screwy hardware serial number representation (sometimes hex digits of ASCII, sometimes ASCII, character pairs inverted). While the giant pachinko machine known as the heavyweight WMI Service (often disabled or removed from machines for security) probably has a larger rules database for decoding such things it is also known to miss things for some drives. See the comments, many systems will report SATA drives as ATA due to design limitations in Windows. Google ATAPortInfo.docx for details.
Any software I post in these forums written by me is provided “AS IS” without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. Please understand that I’ve been programming since the mid-1970s and still have some of that code. My contemporary VB6 project is approaching 1,000 modules. In addition, I have a “VB6 random code folder” that is overflowing. I’ve been at this long enough to truly not know with absolute certainty from whence every single line of my code has come, with much of it coming from programmers under my employ who signed intellectual property transfers. I have not deliberately attempted to remove any licenses and/or attributions from any software.
If someone finds that I have inadvertently done so, I sincerely apologize, and, upon notice and reasonable proof, will re-attach those licenses and/or attributions. To all, peace and happiness. As I said it has warts. Feel free to point me to another example that works! I could use it myself. This is tricky stuff though, Windows was not designed to offer it up to applications easily.
A lot of criticism for a free code handout. There are other routes that can be taken that require priviledge elevation, and they may work better but I don't have any working code to share. WMI is useless because it may be disabled or not installed at all.
The code attached above was designed with the goal of not requiring elevation so it might be used in normal applications. Those would typically only look at the system drive or at the 'running from' USB flash drive in the case of a portable application.
Seems to work fine here on XP for the system drive. I haven't tested USB flash drives on XP.
I don't have any floppy drives or RAID drive configurations so those have never been tested (and thus never debugged). Hopefully somebody can help modify this to do a better job. I'd like USB hard drive serial numbers myself, but I get back an opaque string of hex digits when I try it.
Yeah, it seems to be a pretty tough thing to accomplish in general. I'm sure that's why WMI often fails to return anything or appears to return 'junk.' For local (ATA, SATA) hard drives that are 'ready' (not RAID members) you can get back either ASCII with the characters inverted in pairs with leading or trailing spaces or even ASCII hex digits of ASCII values with the characters inverted in pairs with leading or trailing spaces: 'WD-12345' as '************DW1-3254' where '*' is a space 'WD-12345' as '2D33323534' USB drives always give back Unicode hex digits. Free Msp Codes Generator Not Putting. The values from USB hard drives are garbage (or obfuscated), as confirmed by disk vendor utilities that can report the real serial number.
I'm suspicious of the values for flash drives but the available 'lore' suggests this is correct. Any software I post in these forums written by me is provided “AS IS” without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. Please understand that I’ve been programming since the mid-1970s and still have some of that code. My contemporary VB6 project is approaching 1,000 modules. In addition, I have a “VB6 random code folder” that is overflowing. I’ve been at this long enough to truly not know with absolute certainty from whence every single line of my code has come, with much of it coming from programmers under my employ who signed intellectual property transfers. I have not deliberately attempted to remove any licenses and/or attributions from any software.