Hi,
I found the following script on the MS site and i'm having trouble converting it to work the way I want. I'm trying to find the physical disk from a given volume label. Here is the original script:
and I've tried to convert it like this:
Every time I run my version it errors out with a 0x8004103A
Please can you help me as this is driving me nuts!
Many thanks,
Greg.
I found the following script on the MS site and i'm having trouble converting it to work the way I want. I'm trying to find the physical disk from a given volume label. Here is the original script:
Code:
'---------------------------
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colDiskDrives = objWMIService.ExecQuery("SELECT * FROM Win32_DiskDrive")
For Each objDrive In colDiskDrives
Wscript.Echo "Physical Disk: " & objDrive.Caption & " -- " & objDrive.DeviceID
strDeviceID = Replace(objDrive.DeviceID, "\", "\\")
Set colPartitions = objWMIService.ExecQuery _
("ASSOCIATORS OF {Win32_DiskDrive.DeviceID=""" & _
strDeviceID & """} WHERE AssocClass = " & _
"Win32_DiskDriveToDiskPartition")
For Each objPartition In colPartitions
Wscript.Echo "Disk Partition: " & objPartition.DeviceID
Set colLogicalDisks = objWMIService.ExecQuery _
("ASSOCIATORS OF {Win32_DiskPartition.DeviceID=""" & _
objPartition.DeviceID & """} WHERE AssocClass = " & _
"Win32_LogicalDiskToPartition")
For Each objLogicalDisk In colLogicalDisks
Wscript.Echo "Logical Disk: " & objLogicalDisk.DeviceID
Next
Wscript.Echo
Next
Wscript.Echo
Next
'---------------------------
and I've tried to convert it like this:
Code:
'---------------------------
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colLogicalDisks = objWMIService.ExecQuery _
("Select * From Win32_LogicalDisk Where VolumeName = 'System'")
For Each objLogicalDisk In colLogicalDisks
WScript.Echo "Logical Disk: " & objLogicalDisk.DeviceID
Set colPartitions = objWMIService.ExecQuery _
("ASSOCIATORS OF {Win32_LogicalDiskToPartition.DeviceID=""" & _
objLogicalDisk.DeviceID & """} WHERE AssocClass = " & _
"Win32_DiskPartition")
For Each objPartition In colPartitions
Wscript.Echo "Disk Partition: " & objPartition.DeviceID
Set colDiskDrives = objWMIService.ExecQuery _
("ASSOCIATORS OF {Win32_DiskDriveToDiskPartition.DeviceID=""" & _
objPartition.DeviceID & """} WHERE AssocClass = " & _
"Win32_DiskDrive")
For Each objDrive In colDiskDrives
Wscript.Echo "Physical Disk: " & objDrive.DeviceID
Next
Next
Next
'---------------------------
Every time I run my version it errors out with a 0x8004103A
Please can you help me as this is driving me nuts!
Many thanks,
Greg.