Solved

Uisng WMIC to do a WQL Select statement

Posted on 2006-11-13
3
1,372 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Visual Studio 2005 text editor 10 38
Zip Folders Using Chilkat Routines 1 40
VB6 - Scroll Mouse wheel on Picturebox 13 44
backup program with robocopy 6 18
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

777 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