If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Rate Thread | Display Modes |
#16
|
|||
|
|||
SSDs serial No in BIOS.
"Andy Burns" wrote
| from within a cmd.exe window, try | | wmic.exe diskdrive get serialnumber | It's not clear to me how a serial number is going to help Peter Jason. Serial numbers are mostly for commercial use. If he doesn't know which disk he cloned he could always put piece of tape on one of them, no? In any case.... What you're doing is the same thing as what Garry is doing. He's using WMI via script. You're using a WMI wrapper applet for command line. Both are using WMI. (Most 3rd party system info utilities also use WMI. So it's worthwhile getting it from the horse's mouth.) The only difference is that he was listing logical disks (partitions) rather than physical disks. For physical disks you can get all kinds of info. SerialNumber is available after XP. If one needs to deal with XP then DeviceID can be used. (SCSIPort might also be useful, but on my current machine it just returns 0.) Either way, whatever you get will be the same via either method. wmic.exe is just a wrapper to allow people using PowerShell to access WMI. For anyone who knows scripting or software programming, those methods will be a lot easier and far more flexible than command line. wmic is a kind of training wheels method to get single, specific properties without needing to learn about WMI. It's one of the many things designed for IT people so that they can do their job using one-line incantations that can be shared and found online, without having to learn the whole system. For anyone who wants to use WMI..... There's a help file in the Win32 SDK that's indispensible because the methods and properties are vast and the object model is stunningly bad in its design. (Whenever I work with WMI I use a combination of the help file and previous scripts I've written. The syntax is tragically non-intuitive, so I find it easier to just adapt things I've written before. As can be seen from your sample, wmic is not designed in accord with WMI, so while your method is good once you know it, you'll need a wmic reference in order to use it for anything more than a snippet here or there. Specifically in this case, WMI has no "diskdrive" object. That's a corruption introduced by wmic.exe. (Corruption may seem a strong word, but designing things that way confuses people and makes the job harder for everyone. The object in WMI is Win32_DiskDrive. Admittedly, that's a sorry excuse for an object name... No one should ever have to type underscores and the "Win32" part is superfluous.... but MS screwed it up and there's no going back. Yet with wmic they apparently decided to simplify it. But since wmic is not following the WMI object model, no amount of experience with WMI will allow one to predict the correct call to make to wmic for any specific info! That's much worse than re-using bad object names. It's like writing a cookbook and deciding to rename recipes, like renaming Baked Alaska to Flaming Ice Cream. No one will know to look up Flaming Ice Cream. And everyone will be confused when their guests are served Baked Alaska under a pseudonym.) The following VBScript shows some of the properties available from Win32_DiskDrive. Copy to Notepad, save as something.vbs, double-click to see a report: Dim WMI, Col, Ob, s2, s3 On Error Resume Next Set WMI = GetObject("WinMgmts:") Set Col = WMI.ExecQuery("Select * from Win32_DiskDrive") s2 = "Drives:" & vbCrLf & vbCrLf For Each Ob in Col s2 = s2 & "Description: " & Ob.Description & vbCrLf s2 = s2 & "Manufacturer: " & Ob.Manufacturer & vbCrLf s2 = s2 & "Model: " & Ob.Model & vbCrLf s2 = s2 & "InterfaceType: " & Ob.InterfaceType & vbCrLf s2 = s2 & "MediaType: " & Ob.MediaType & vbCrLf s2 = s2 & "DeviceID: " & Ob.DeviceID & vbCrLf '-- This next only available on Vista+ s2 = s2 & "SerialNumber: " & Ob.SerialNumber & vbCrLf s2 = s2 & "Number of Win Partitions: " & Ob.Partitions & vbCrLf s3 = CStr(Ob.Size) If Len(s3) 9 Then s3 = Left(s3, (len(s3) - 9)) s2 = s2 & "Size (GB): " & s3 End If s2 = s2 & vbCrLf & vbCrLf Next Set Col = Nothing Set WMI = Nothing MsgBox s2 '--------------------------------------- For what it's worth, here's one I use to do a quick survey of hardware on a system. It writes a report to C:\Sysinfo.txt: '---------------------------------- Dim WMI, Col, Ob, S2, i2, s3, sFil, sBul, sLine '-- path to save data. ------------------ sFil = "C:\Sysinfo.txt" sBul = " " & Chr(149) & " " sLine = vbCrLf & "_____________________________________________ " & vbCrLf & vbCrLf Err.Clear On Error Resume Next Set WMI = GetObject("WinMgmts:") If (Err.number 0) Then MsgBox "Error creating WMI object. Error: " & Err.Number & " - " & Err.Description WScript.quit End If '-------------- product ------------------------------------ Set Col = WMI.ExecQuery("Select * from Win32_ComputerSystemProduct") S2 = S2 & sBul & " Product Info:" & vbCrLf & vbCrLf For Each Ob in Col S2 = S2 & "Product Name: " & Ob.Name & vbCrLf S2 = S2 & "Product Version: " & Ob.Version & vbCrLf S2 = S2 & "Product Description: " & Ob.Description & vbCrLf S2 = S2 & "IdentifyingNumber: " & Ob.IdentifyingNumber & vbCrLf S2 = S2 & "Product UUID: " & Ob.UUID & vbCrLf Next S2 = S2 & sLine '-- box id -------------------------------------------------------------------- Set Col = WMI.ExecQuery("Select * from Win32_SystemEnclosure") S2 = S2 & sBul & "Machine ID (SystemEnclosure) info:" & vbCrLf & vbCrLf For Each Ob in Col S2 = S2 & "Part Number: " & Ob.PartNumber & vbCrLf S2 = S2 & "Serial Number: " & Ob.SerialNumber & vbCrLf S2 = S2 & "Asset Tag: " & Ob.SMBIOSAssetTag & vbCrLf Next S2 = S2 & sLine '-- motherboard -------------------------------------------------------------------- Set Col = WMI.ExecQuery("Select * from Win32_MotherboardDevice") S2 = S2 & sBul & "Motherboard info:" & vbCrLf & vbCrLf For Each Ob in Col S2 = S2 & "Caption: " & Ob.Caption & vbCrLf S2 = S2 & "InstallDate: " & Ob.InstallDate & vbCrLf S2 = S2 & "DeviceID: " & Ob.DeviceID & vbclrf Next S2 = S2 & vbCrLf '----------- bios ----------------------------------- Set Col = WMI.ExecQuery("Select * from Win32_BIOS") S2 = S2 & sBul & "BIOS info:" & vbCrLf & vbCrLf For Each Ob in Col S2 = S2 & "Manufacturer: " & Ob.Manufacturer & vbCrLf S2 = S2 & "Description: " & Ob.Description & vbCrLf S2 = S2 & "Version: " & Ob.Version & vbCrLf S2 = S2 & "InstallDate: " & Ob.InstallDate & vbCrLf S2 = S2 & "SerialNumber: " & Ob.SerialNumber & vbCrLf Next S2 = S2 & sLine '-- CPU -------------------------------------------------------------------- Set Col = WMI.ExecQuery("Select * from Win32_Processor") S2 = S2 & sBul & "CPU:" & vbCrLf & vbCrLf For Each Ob in Col S2 = S2 & "Manufacturer: " & Ob.Manufacturer & vbCrLf S2 = S2 & "Description: " & Ob.Description & vbCrLf S2 = S2 & "Name: " & Ob.Name & vbCrLf S2 = S2 & "Speed: " & Ob.MaxClockSpeed & sLine Next '-- RAM and product info. -------------------------------------------------------------------- Set Col = WMI.ExecQuery("Select * from Win32_ComputerSystem") S2 = S2 & sBul & "Installed RAM: " For Each Ob in Col i2 = Ob.TotalPhysicalMemory If i2 0 Then i2 = i2 \ 1024 \ 1024 S2 = S2 & CStr(i2) & " MB" & vbCrLf End If S2 = S2 & sLine Next S2 = S2 & sBul & "PC Info.:" & vbCrLf &vbCrLf For Each Ob in Col S2 = S2 & "PC or motherboard model: " & Ob.Model & vbCrLf S2 = S2 & "System name: " & Ob.Name & vbCrLf S2 = S2 & "System Manufacturer: " & Ob.Manufacturer & vbCrLf Next S2 = S2 & sLine '---------- onboard devices ---------------------------------------- Set Col = WMI.ExecQuery("Select * from Win32_OnBoardDevice") S2 = S2 & sBul & "Onboard devices:" & vbCrLf & vbCrLf For Each Ob in Col S2 = S2 & "Description: " & Ob.Description & vbCrLf S2 = S2 & "Name: " & Ob.Name & vbCrLf S2 = S2 & "Manufacturer: " & Ob.Manufacturer & vbCrLf S2 = S2 & "Model: " & Ob.Model & vbCrLf & vbCrLf Next S2 = S2 & sLine '-- graphics -------------------------------------------------------------------- Set Col = WMI.ExecQuery("Select * from Win32_VideoController") S2 = S2 & sBul & "Graphics:" & vbCrLf & vbCrLf For Each Ob in Col S2 = S2 & "Description: " & Ob.Description & vbCrLf S2 = S2 & "Name: " & Ob.Name & vbCrLf i2 = Ob.AdapterRAM If i2 0 Then i2 = i2 \ 1024 \ 1024 S2 = S2 & "RAM: " & " MB" & vbCrLf End If S2 = S2 & "Driver Date: " & Ob.DriverDate & vbCrLf S2 = S2 & "Driver Version: " & Ob.DriverVersion & vbCrLf Next S2 = S2 & sLine '-- hard disks -------------------------------------------------------------------- Set Col = WMI.ExecQuery("Select * from Win32_DiskDrive") S2 = S2 & sBul & "Drives:" & vbCrLf & vbCrLf For Each Ob in Col S2 = S2 & "Description: " & Ob.Description & vbCrLf S2 = S2 & "Manufacturer: " & Ob.Manufacturer & vbCrLf S2 = S2 & "Model: " & Ob.Model & vbCrLf S2 = S2 & "InterfaceType: " & Ob.InterfaceType & vbCrLf S2 = S2 & "MediaType: " & Ob.MediaType & vbCrLf S2 = S2 & "DeviceID: " & Ob.DeviceID & vbCrLf S2 = S2 & "Number of Win Partitions: " & Ob.Partitions & vbCrLf s3 = CStr(Ob.Size) If Len(s3) 9 Then s3 = Left(s3, (len(s3) - 9)) S2 = S2 & "Size (GB): " & s3 End If S2 = S2 & vbCrLf & vbCrLf Next S2 = S2 & sLine '-- CD/DVD drives -------------------------------------------------------------------- Set Col = WMI.ExecQuery("Select * from Win32_CDROMDrive") S2 = S2 & sBul & "CD/DVD drives:" & vbCrLf & vbCrLf For Each Ob in Col S2 = S2 & "Description: " & Ob.Description & vbCrLf S2 = S2 & "Caption: " & Ob.Caption & vbCrLf S2 = S2 & "Manufacturer: " & Ob.Manufacturer & vbCrLf & vbCrLf Next S2 = S2 & sLine '-- network adapter -------------------------------------------------------------------- Set Col = WMI.ExecQuery("Select * from Win32_NetworkAdapter") S2 = S2 & sBul & "Network Adapter:" & vbCrLf & vbCrLf For Each Ob in Col S2 = S2 & "Description: " & Ob.Description & vbCrLf S2 = S2 & "Name: " & Ob.ProductName & vbCrLf S2 = S2 & "Manufacturer: " & Ob.Manufacturer & vbCrLf S2 = S2 & "MAC Address: " & Ob.MACAddress & vbCrLf & vbCrLf Next S2 = S2 & sLine Set Col = Nothing Set WMI = Nothing Dim FSO, TS Set FSO = CreateObject("Scripting.FileSystemObject") Set TS = FSO.CreateTextFile(sFil, True) TS.Write S2 TS.Close Set TS = Nothing Set FSO = Nothing MsgBox "Done." |
Ads |
#17
|
|||
|
|||
SSDs serial No in BIOS.
Mayayana wrote:
In any case.... What you're doing is the same thing as what Garry is doing. He's using WMI via script. You're using a WMI wrapper applet for command line. Both are using WMI. No, not the same ... mine is retrieving the physical disc's serial number set in the facctory, which should correspond to the serial number printed on the disk itself; Garry is retrieving the logical drive letter's volume serial, written whenever a partition is formatted, and will probably be the same on a cloned disk as the disk it was cloned from. |
#18
|
|||
|
|||
SSDs serial No in BIOS.
Mayayana wrote:
In any case.... What you're doing is the same thing as what Garry is doing. He's using WMI via script. You're using a WMI wrapper applet for command line. Both are using WMI. No, not the same ... mine is retrieving the physical disc's serial number set in the facctory, which should correspond to the serial number printed on the disk itself; Garry is retrieving the logical drive letter's volume serial, written whenever a partition is formatted, and will probably be the same on a cloned disk as the disk it was cloned from. See my latest reply... -- Garry Free usenet access at http://www.eternal-september.org Classic VB Users Regroup! comp.lang.basic.visual.misc microsoft.public.vb.general.discussion |
#19
|
|||
|
|||
SSDs serial No in BIOS.
"Andy Burns" wrote
| In any case.... | What you're doing is the same thing as what Garry | is doing. He's using WMI via script. You're using a WMI | wrapper applet for command line. Both are using WMI. | | No, not the same ... mine is retrieving the physical disc's serial | number set in the facctory, which should correspond to the serial number | printed on the disk itself; Please reread. What I'm saying is that you are both using WMI. You may not know it, but wmic is just a wrapper around WMI. In other words, both methods can be used. Garry was just retrieving different info from what you were retrieving: Win32_LogicialDisk vs Win32_DiskDrive What I posted was the Win32_DiskDrive equivalent of Garry's code. Win32_DiskDrive has a SerialNumber property. What I posted was just the scripted, direct-from-WMI version of your method. *It's all coming from the same place.* (Note that DeviceID also returns a unique value: The order of the disk as the system sees it: disk 0, disk 1, etc.) |
#20
|
|||
|
|||
SSDs serial No in BIOS.
Mayayana wrote:
What I'm saying is that you are both using WMI. You may not know it Of course I know it, the clue is in the name; I was complaining about *WHAT* was being retrieved, rather than *HOW* |
#21
|
|||
|
|||
SSDs serial No in BIOS.
"Andy Burns" wrote
In any case.... What you're doing is the same thing as what Garry is doing. He's using WMI via script. You're using a WMI wrapper applet for command line. Both are using WMI. No, not the same ... mine is retrieving the physical disc's serial number set in the facctory, which should correspond to the serial number printed on the disk itself; Please reread. What I'm saying is that you are both using WMI. You may not know it, but wmic is just a wrapper around WMI. In other words, both methods can be used. Garry was just retrieving different info from what you were retrieving: Win32_LogicialDisk vs Win32_DiskDrive What I posted was the Win32_DiskDrive equivalent of Garry's code. Win32_DiskDrive has a SerialNumber property. What I posted was just the scripted, direct-from-WMI version of your method. *It's all coming from the same place.* (Note that DeviceID also returns a unique value: The order of the disk as the system sees it: disk 0, disk 1, etc.) None of that matters if the return doesn't associate the serial# with its respective drive, which Andy's cmd line approach doesn't do. See my last reply for a better solution... -- Garry Free usenet access at http://www.eternal-september.org Classic VB Users Regroup! comp.lang.basic.visual.misc microsoft.public.vb.general.discussion |
#22
|
|||
|
|||
SSDs serial No in BIOS.
Andy Burns wrote:
Mayayana wrote: What I'm saying is that you are both using WMI. You may not know it Of course I know it, the clue is in the name; I was complaining about *WHAT* was being retrieved, rather than *HOW* The two drives can be told apart, by their Power-On-Hours field in SMART. One drive claims to be brand new. The POH should have a low numerical value. While you're reviewing the POH in HTTune SMART tab, you can flip to the Info tab and review SerialNumber. And HDTune disks should be in the same order as Disk Management. Using WMIC and PhysicalDisk versus SerialNumber, should show the same pattern. Paul |
#23
|
|||
|
|||
SSDs serial No in BIOS.
"GS" wrote
| What I posted was the Win32_DiskDrive equivalent of | Garry's code. Win32_DiskDrive has a SerialNumber property. | What I posted was just the scripted, direct-from-WMI | version of your method. *It's all coming from the same | place.* (Note that DeviceID also returns a | unique value: The order of the disk as the system | sees it: disk 0, disk 1, etc.) | | None of that matters if the return doesn't associate the serial# with its | respective drive, which Andy's cmd line approach doesn't do. See my last reply | for a better solution... I'm not sure that's better. Peter seemed to be saying that one disk was not mounted. So it wouldn't have drive letters. Also, DeviceID will show the order they're plugged in. Presumably SATA0 will show as disk0. Personally, I still think a piece of tape on one of them is a better method. His actual question seemed to be theoretical rather than practical. If he doesn't know which disk is new and which is old when looking in the case then a piece of tape will solve that. Since he's cloning for replacement, he really has no need to tell them apart from inside Windows. He's not going to be running both. |
#24
|
|||
|
|||
SSDs serial No in BIOS.
Andy Burns wrote:
Mayayana wrote: What I'm saying is that you are both using WMI. You may not know it Of course I know it, the clue is in the name; I was complaining about *WHAT* was being retrieved, rather than *HOW* The two drives can be told apart, by their Power-On-Hours field in SMART. One drive claims to be brand new. The POH should have a low numerical value. While you're reviewing the POH in HTTune SMART tab, you can flip to the Info tab and review SerialNumber. And HDTune disks should be in the same order as Disk Management. Using WMIC and PhysicalDisk versus SerialNumber, should show the same pattern. Paul What Namespace contains 'PhysicalDisk'? (Not in CIMV2, which is what I'm using) -- Garry Free usenet access at http://www.eternal-september.org Classic VB Users Regroup! comp.lang.basic.visual.misc microsoft.public.vb.general.discussion |
#25
|
|||
|
|||
SSDs serial No in BIOS.
GS wrote:
Grrr...I converted my script to get a USB PNPDeviceID to suit this task and forgot to edit the USB to read IDE Yep, that works (provided the drive letter is entered in upper case) I'd still go with a one-liner wmic.exe diskdrive get index,serialnumber and compare the drive index number to what diskpart.exe or diskmgmt.msc show. |
#26
|
|||
|
|||
SSDs serial No in BIOS.
"GS" wrote
What I posted was the Win32_DiskDrive equivalent of Garry's code. Win32_DiskDrive has a SerialNumber property. What I posted was just the scripted, direct-from-WMI version of your method. *It's all coming from the same place.* (Note that DeviceID also returns a unique value: The order of the disk as the system sees it: disk 0, disk 1, etc.) None of that matters if the return doesn't associate the serial# with its respective drive, which Andy's cmd line approach doesn't do. See my last reply for a better solution... I'm not sure that's better. Peter seemed to be saying that one disk was not mounted. I didn't catch that since he's trying to retrieve the serial#s programmatically suggests both are mounted. You could very well be right if the machine doesn't have 2 SSD slots. So it wouldn't have drive letters. Also, DeviceID will show the order they're plugged in. Presumably SATA0 will show as disk0. The context of DeviceID in my use is to verify the DriveLetter of the drive matches the value returned by InputBox. In LogicalDisk, both DeviceID and Caption return the drive Path. Personally, I still think a piece of tape on one of them is a better method. His actual question seemed to be theoretical rather than practical. If he doesn't know which disk is new and which is old when looking in the case then a piece of tape will solve that. Since he's cloning for replacement, he really has no need to tell them apart from inside Windows. He's not going to be running both. -- Garry Free usenet access at http://www.eternal-september.org Classic VB Users Regroup! comp.lang.basic.visual.misc microsoft.public.vb.general.discussion |
#27
|
|||
|
|||
SSDs serial No in BIOS.
GS wrote:
Grrr...I converted my script to get a USB PNPDeviceID to suit this task and forgot to edit the USB to read IDE Yep, that works (provided the drive letter is entered in upper case) Modify the script to trap that! I'd still go with a one-liner wmic.exe diskdrive get index,serialnumber and compare the drive index number to what diskpart.exe or diskmgmt.msc show. Uh, isn't that more work? -- Garry Free usenet access at http://www.eternal-september.org Classic VB Users Regroup! comp.lang.basic.visual.misc microsoft.public.vb.general.discussion |
#28
|
|||
|
|||
SSDs serial No in BIOS.
I'm not sure that's better. Peter seemed to
be saying that one disk was not mounted. I didn't catch that since he's trying to retrieve the serial#s programmatically suggests both are mounted. You could very well be right if the machine doesn't have 2 SSD slots. Ok, a reread sees he's swapping them to test. -- Garry Free usenet access at http://www.eternal-september.org Classic VB Users Regroup! comp.lang.basic.visual.misc microsoft.public.vb.general.discussion |
#29
|
|||
|
|||
SSDs serial No in BIOS.
GS wrote:
Uh, isn't that more work? But the O/P says he has one of the disks "offline" in disk management, so no logical drive letter, only a physical disk number |
#30
|
|||
|
|||
SSDs serial No in BIOS.
GS wrote:
Uh, isn't that more work? But the O/P says he has one of the disks "offline" in disk management, so no logical drive letter, only a physical disk number I thought he was unpluging/swapping them to test. -- Garry Free usenet access at http://www.eternal-september.org Classic VB Users Regroup! comp.lang.basic.visual.misc microsoft.public.vb.general.discussion |
Thread Tools | |
Display Modes | Rate This Thread |
|
|