Solved

Uisng WMIC to do a WQL Select statement

Posted on 2006-11-13
3
1,361 Views
Last Modified: 2012-08-14
I have a WQL select statement and a target names space. Can you help me from the WMIC prompt correctly execute this statement?

namespace = root\sms\site_b02
query         = Select * from SMS_ConfigurationItem

I apprecaite your assistance.

Thanks,
JohnD
0
Comment
Question by:johndarby
  • 2
3 Comments
 
LVL 12

Accepted Solution

by:
jkaios earned 500 total points
ID: 17935190
Private Sub Form_Load()
   EnumServices "localhost"
End Sub

Public Sub EnumServices(sMachine As String, Optional sUserName As String, Optional sPassword As String)

   Dim oLocator     As Object
   Dim oServices    As Object
   Dim objEnum      As Object
   Dim objInstance  As Object
   Dim sQuery       As String
   
   sQuery = "SELECT * FROM SMS_ConfigurationItem"
   
   Set oLocator = CreateObject("WbemScripting.SWbemLocator")
   Set oServices = oLocator.ConnectServer(sMachine, "root\cimv2", sUserName, sPassword)
   Set objEnum = oServices.ExecQuery(sQuery)
   
   If Err Then
      Debug.Print "Error 0x" & Hex(Err.Number) & " - " & Err.Description
      Exit Sub
   End If
   
   For Each objInstance In objEnum
      With objInstance
         Debug.Print "Name: " & .Name
      End With
   Next
   
End Sub
0
 
LVL 1

Author Comment

by:johndarby
ID: 17940157
This is a great answer for the other question (WMI query using VBScript). But, I believe this line...

Set oServices = oLocator.ConnectServer(sMachine, "root\cimv2", sUserName, sPassword)

should read...

Set oServices = oLocator.ConnectServer(sMachine, "root\sms\site_<site#>", sUserName, sPassword)
0
 
LVL 1

Author Comment

by:johndarby
ID: 17940179
What I am seeking here is help usig WMIC, the WMI console.

Thanks,
JohnD
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now