I can use the following code to get the partition details from my local system, by specifying the server name explicitly or as ".".
However, if I try to name another machine on the network, the programme hangs until I click the form.
I then get a message titled: "Component Request Pending", with the following text:
"The action cannot be completed because the other application is busy. Choose 'Switch To' to activate the busy application and correct the problem."
Clicking on the 'Switch To' button on the dialogue causes it to reappear until this debug message :
Run-time error '462': The remote server machine does nort exist or is unavailale. Clicking on Debug causes a halt on this line:
Set objWMI = GetObject("winmgmts:\\" & strServer & "\root\cimv2")
Sub GetLetterDrivePartition()
Dim colItems As Object
Dim objItem As Object
Dim rs As New Recordset
Dim objWMI
'Const strServer = "."
'Const strServer = "grahamwks"
Const strServer = "toshiba"
Const wbemFlagReturnImmediately = &H10
Const wbemFlagForwardOnly = &H20
Set objWMI = GetObject("winmgmts:\\" & strServer & "\root\cimv2")
Set colItems = objWMI.ExecQuery("Select * From Win32_LogicalDiskToPartiti
on", "WQL", _
wbemFlagReturnImmediately + wbemFlagForwardOnly)
'Debug.Print Time & " " & Dir$("\\" & strServer & "\My Documents\*", vbDirectory)
rs.Open "Letter_DriveNo_PartitionN
o", cnn, adOpenDynamic, adLockPessimistic, adCmdTable
For Each objItem In colItems
Debug.Print Time & " " & objItem.Dependent
'\\GRAHAMWKS\root\cimv2:Wi
n32_Logica
lDisk.Devi
ceID="C:"
Debug.Print Time & " " & objItem.Antecedent
'\\GRAHAMWKS\root\cimv2:Wi
n32_DiskPa
rtition.De
viceID="Di
sk #0, Partition #0"
rs.AddNew
rs.Fields("Server").Value = Split(objItem.Dependent, "\")(2)
rs.Fields("Letter").Value = Left$(Right(objItem.Depend
ent, 3), 1)
rs.Fields("DiskNo").Value = Left$(Split(objItem.Antece
dent, "Disk #")(1), 1)
rs.Fields("PartitionNo").V
alue = Left$(Right$(objItem.Antec
edent, 2), 1)
rs.Fields("RunDate").Value
= Now
rs.Update
Next objItem
Set objWMI = Nothing
End Sub
The program runs on Windows 2000. The target systems are 2000 and XP.
Start Free Trial