The script shows us info about the drive:
import win32com
from win32com import client
strComputer = "."
objWMIService = win32com.client.Dispatch("WbemScripting.SWbemLocator")
objSWbemServices = objWMIService.ConnectServer(strComputer,"root\cimv2")
out_items = objSWbemServices.ExecQuery("SELECT * FROM Win32_DiskDrive")
for object_item in out_items:
if object_item.Availability != None:
print("Availability:" + str(object_item.Availability))
if object_item.BytesPerSector != None:
print("BytesPerSector:" + str(object_item.BytesPerSector))
print("Capabilities:")
strList = " "
try :
for obj_element in object_item.Capabilities :
strList = strList + 'obj_element' + "," + obj_element
except:
strList = strList + 'null'
print(strList)
print("CapabilityDescriptions:")
strList = " "
try :
for obj_element in object_item.CapabilityDescriptions :
strList = strList + 'obj_element' + "," + obj_element
except:
strList = strList + 'null'
print(strList)
if object_item.Caption != None:
print("Caption:" + str(object_item.Caption))
if object_item.CompressionMethod != None:
print("CompressionMethod:" + str(object_item.CompressionMethod))
if object_item.ConfigManagerErrorCode != None:
print("ConfigManagerErrorCode:" + str(object_item.ConfigManagerErrorCode))
if object_item.ConfigManagerUserConfig != None:
print("ConfigManagerUserConfig:" + str(object_item.ConfigManagerUserConfig))
if object_item.CreationClassName != None:
print("CreationClassName:" + str(object_item.CreationClassName))
if object_item.DefaultBlockSize != None:
print("DefaultBlockSize:" + str(object_item.DefaultBlockSize))
if object_item.Description != None:
print("Description:" + str(object_item.Description))
if object_item.DeviceID != None:
print("DeviceID:" + str(object_item.DeviceID))
if object_item.ErrorCleared != None:
print("ErrorCleared:" + str(object_item.ErrorCleared))
if object_item.ErrorDescription != None:
print("ErrorDescription:" + str(object_item.ErrorDescription))
if object_item.ErrorMethodology != None:
print("ErrorMethodology:" + str(object_item.ErrorMethodology))
if object_item.Index != None:
print("Index:" + str(object_item.Index))
#object_item.InstallDate - this is not show
if object_item.InterfaceType != None:
print("InterfaceType:" + str(object_item.InterfaceType))
if object_item.LastErrorCode != None:
print("LastErrorCode:" + str(object_item.LastErrorCode))
if object_item.Manufacturer != None:
print("Manufacturer:" + str(object_item.Manufacturer))
if object_item.MaxBlockSize != None:
print("MaxBlockSize:" + str(object_item.MaxBlockSize))
if object_item.MaxMediaSize != None:
print("MaxMediaSize:" + str(object_item.MaxMediaSize))
if object_item.MediaLoaded != None:
print("MediaLoaded:" + str(object_item.MediaLoaded))
if object_item.MediaType != None:
print("MediaType:" + str(object_item.MediaType))
if object_item.MinBlockSize != None:
print("MinBlockSize:" + str(object_item.MinBlockSize))
if object_item.Model != None:
print("Model:" + str(object_item.Model))
if object_item.Name != None:
print("Name:" + str(object_item.Name))
if object_item.NeedsCleaning != None:
print("NeedsCleaning:" + str(object_item.NeedsCleaning))
if object_item.NumberOfMediaSupported != None:
print("NumberOfMediaSupported:" + str(object_item.NumberOfMediaSupported))
if object_item.Partitions != None:
print("Partitions:" + str(object_item.Partitions))
if object_item.PNPDeviceID != None:
print("PNPDeviceID:" + str(object_item.PNPDeviceID))
print("PowerManagementCapabilities:")
strList = " "
try :
for obj_element in object_item.PowerManagementCapabilities :
strList = strList + 'obj_element' + "," + obj_element
except:
strList = strList + 'null'
print(strList)
if object_item.PowerManagementSupported != None:
print("PowerManagementSupported:" + str(object_item.PowerManagementSupported))
if object_item.SCSIBus != None:
print("SCSIBus:" + str(object_item.SCSIBus))
if object_item.SCSILogicalUnit != None:
print("SCSILogicalUnit:" + str(object_item.SCSILogicalUnit))
if object_item.SCSIPort != None:
print("SCSIPort:" + str(object_item.SCSIPort))
if object_item.SCSITargetId != None:
print("SCSITargetId:" + str(object_item.SCSITargetId))
if object_item.SectorsPerTrack != None:
print("SectorsPerTrack:" + str(object_item.SectorsPerTrack))
if object_item.Signature != None:
print("Signature:" + str(object_item.Signature))
if object_item.Size != None:
print("Size:" + str(object_item.Size))
if object_item.Status != None:
print("Status:" + str(object_item.Status))
if object_item.StatusInfo != None:
print("StatusInfo:" + str(object_item.StatusInfo))
if object_item.SystemCreationClassName != None:
print("SystemCreationClassName:" + str(object_item.SystemCreationClassName))
if object_item.SystemName != None:
print("SystemName:" + str(object_item.SystemName))
if object_item.TotalCylinders != None:
print("TotalCylinders:" + str(object_item.TotalCylinders))
if object_item.TotalHeads != None:
print("TotalHeads:" + str(object_item.TotalHeads))
if object_item.TotalSectors != None:
print("TotalSectors:" + str(object_item.TotalSectors))
if object_item.TotalTracks != None:
print("TotalTracks:" + str(object_item.TotalTracks))
if object_item.TracksPerCylinder != None:
print("TracksPerCylinder:" + str(object_item.TracksPerCylinder))
The result looks something like this:MediaLoaded:True
...
MediaType:Fixed hard disk media
Model:TOSHIBA MQ01ABF050
Name:\\.\PHYSICALDRIVE0
Partitions:2
PNPDeviceID:SCSI\DISK&VEN_TOSHIBA&PROD_MQ01ABF050\4&AD866E5&0&000000
PowerManagementCapabilities:
null
SCSIBus:0
SCSILogicalUnit:0
SCSIPort:0
SCSITargetId:0
SectorsPerTrack:63
Signature:-1846003871
Size:500105249280
Status:OK
SystemCreationClassName:Win32_ComputerSystem
SystemName:CATAFEST
TotalCylinders:60801
TotalHeads:255
TotalSectors:976768065
TotalTracks:15504255
TracksPerCylinder:255