Advertisement

08.25.2007 at 01:15PM PDT, ID: 22787057
[x]
Attachment Details

How should the server be specified in winmgmts calls?

Asked by GrahamSkan in Visual Basic Programming, Microsoft Windows Operating Systems

Tags: winmgmts, 462, server

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_LogicalDiskToPartition", "WQL", _
    wbemFlagReturnImmediately + wbemFlagForwardOnly)
    'Debug.Print Time & " " & Dir$("\\" & strServer & "\My Documents\*", vbDirectory)
    rs.Open "Letter_DriveNo_PartitionNo", cnn, adOpenDynamic, adLockPessimistic, adCmdTable
    For Each objItem In colItems
        Debug.Print Time & " " & objItem.Dependent
        '\\GRAHAMWKS\root\cimv2:Win32_LogicalDisk.DeviceID="C:"
        Debug.Print Time & " " & objItem.Antecedent
        '\\GRAHAMWKS\root\cimv2:Win32_DiskPartition.DeviceID="Disk #0, Partition #0"
        rs.AddNew
         rs.Fields("Server").Value = Split(objItem.Dependent, "\")(2)
         rs.Fields("Letter").Value = Left$(Right(objItem.Dependent, 3), 1)
         rs.Fields("DiskNo").Value = Left$(Split(objItem.Antecedent, "Disk #")(1), 1)
         rs.Fields("PartitionNo").Value = Left$(Right$(objItem.Antecedent, 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
 
Loading Advertisement...
 
[+][-]08.25.2007 at 05:00PM PDT, ID: 19769589

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]09.12.2007 at 11:04AM PDT, ID: 19878613

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Visual Basic Programming, Microsoft Windows Operating Systems
Tags: winmgmts, 462, server
Sign Up Now!
Solution Provided By: darkstar3d
Participating Experts: 2
Solution Grade: A
 
 
[+][-]09.12.2007 at 11:43AM PDT, ID: 19878879

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.12.2007 at 12:06PM PDT, ID: 19879057

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.15.2007 at 03:02PM PST, ID: 20293630

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628