?
Solved

Uisng WMIC to do a WQL Select statement

Posted on 2006-11-13
3
Medium Priority
?
1,384 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 12

Accepted Solution

by:
jkaios earned 1500 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses
Course of the Month14 days, 12 hours left to enroll

770 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