Results 1 to 5 of 5

Thread: WMI in VB? (VB)

  1. #1
    New Lounger
    Join Date
    Aug 2004
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    WMI in VB? (VB)

    Hi all,

    I have written a load of WMI scripts to do automatic detection for data migration. However, I want to stick a nice VB front end on it; is it possible to natively use WMI in VB or do I have to call the scripts externally? If so, how?

    Thanks in Advance!

    Jamie.

    P.S - Apologies if this is in the wrong forum - was torn between this and the Scripting forum!

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: WMI in VB? (VB)

    Welcome to Woody's Lounge.

    I don't know anything about WMI, but according to Scripting API for WMI,<blockquote><hr>The Microsoft

  3. #3
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Marietta, Georgia, USA
    Posts
    296
    Thanks
    9
    Thanked 4 Times in 4 Posts

    Re: WMI in VB? (VB)

    You can definitely use WMI in VB. There are several examples of using WMI in VBscript on Microsoft technet.:
    http://www.microsoft.com/technet/community...er/default.mspx

    Two of my favorites are Scriptomatic and Tweakomatic:
    http://www.microsoft.com/technet/community...s/wmimatic.mspx
    http://www.microsoft.com/technet/community...s/twkmatic.mspx
    Rick Groszkiewicz
    Life is too short to drink bad wine (or bad coffee!)

  4. #4
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: WMI in VB? (VB)

    Do you have a sample script? Here is a crude representation of the difference between scripting a COM object and automating the same object in VB:

    ' Scripting
    Dim myWMI
    Set myWMI = WScript.CreateObject("wmi.object")

    ' Late binding in VB
    Dim myWMI As object
    Set myWMI = CreateObject("wmi.object")

    ' Early binding in VB
    ' Set reference to object library under Tools>References
    Dim myWMI as wmiObject
    Set myWMI = New wmiObject

    Note: all object names and types are hypothetical.

  5. #5
    New Lounger
    Join Date
    Aug 2004
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: WMI in VB? (VB)

    Thanks for the info guys - am now sorted! I tried the examples then realised i had to add Microsoft Wmi as a reference as well (vb6)! (doh)

    Thanks Again,
    Jamie.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •