View Single Post
  #62  
Old March 20th 18, 11:09 PM posted to alt.comp.os.windows-10
Peter Jason
external usenet poster
 
Posts: 2,310
Default SSDs serial No in BIOS.

On Mon, 19 Mar 2018 18:41:46 -0400, Paul
wrote:

Peter Jason wrote:
On Mon, 19 Mar 2018 15:03:52 -0400, GS wrote:

I can't get it started. How do I get it into the CMD screen? Can it
be started with a RH mouse click?
Either double-click the vbs file OR right-click and choose Open.

I've posted updated scripts since this thread. Here's the final versions:


'GetDriveSerialNumberFromPath.vbs
Dim oWMI, Path, vData, vInfo, sInfo, i, iNdx, bSelectedPath
Set oWMI = GetObject("WinMgmts:")
Path = UCase(InputBox("Enter the Drive Letter"))
Set vData = oWMI.ExecQuery("Select * from Win32_LogicalDisk _
Where DriveType = 3")

i = 0: Path = Left(Path, 1) & ":"
For Each vInfo In vData
'Assign an index only if the USB DeviceID matches Path.
If vInfo.DeviceID = Path Then iNdx = i: bSelectedPath = True: Exit For
i = i + 1
Next

If bSelectedPath Then
'Iterate the WMI.Win32_DiskDrive class to verify Path is a valid USB device,
'and determine an index for identifying our target USB device.
Set vData = oWMI.ExecQuery("Select * from Win32_DiskDrive")
i = 0
For Each vInfo In vData
If UCase(vInfo.InterfaceType) = "IDE" Then
If i = iNdx Then sInfo = Path & " SerialNumber: " _
& vInfo.SerialNumber: Exit For
i = i + 1
End If
Next
End If
MsgBox sInfo, vbInformation


'GetLogicalDiskInfo.vbs
Dim sInfo
Set objWMIService = GetObject("winmgmts:")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_LogicalDisk",,48)
For Each objItem in colItems
sInfo = sInfo & "Caption: " & objItem.Caption & vblf _
& "Description: " & objItem.Description & vblf _
& "VolumeSerialNumber: " & objItem.VolumeSerialNumber & vblf & vblf
Next
MsgBox sInfo, vbInformation


'GetDriveInfo.vbs
Set objWMIService = GetObject("winmgmts:")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_DiskDrive",,48)
For Each objItem in colItems
sInfo = sInfo & "Caption: " & objItem.Caption & vblf _
& "Description: " & objItem.Description & vblf _
& "SerialNumber: " & objItem.SerialNumber & vblf _
& "Size: " & objItem.Size & vblf _
& "---------------------------------------" & vblf
Next
MsgBox sInfo, vbInformation


Thanks, on my machine it gave an error message...
https://postimg.org/image/lt45rd6g5/


Change the fifth line so it isn't extended with the underscore ?

Set vData = oWMI.ExecQuery("Select * from Win32_LogicalDisk Where DriveType = 3")

That got me a result on Win10.

Paul



Thanks, but I get another error message...

https://postimg.org/image/q4y9x0syd/

Ads