Results 1 to 10 of 10

Thread: How make WMI works with xp+sp3 and Vista?

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Feb 2007
    Posts
    18

    Red face How make WMI works with xp+sp3 and Vista?

    With Win XP+Sp2 VB6+sp6 WMI worked perfectly to retrieve Motherboard and CPU serial numbers. But on my friends machines with 1) Win XP+Sp3 and 2) Vista it became completely deaf. I am not authorized to alter the other machines configurations manually (installing or uninstalling).
    How can I solve the problem plz?

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: How make WMI works with xp+sp3 and Vista?

    as you don't show the code you are using hard to say, my wmi program works ok in vista, you probably need to use impersonate, to elevate permissions
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Feb 2007
    Posts
    18

    Re: How make WMI works with xp+sp3 and Vista?

    Thank you very much for your response: here is a piece of code which did not work
    Public Function MBSerialNumber() As String
    Dim objs As Object: Dim obj As Object:
    Dim WMI As Object: Dim sAns As String
    Set WMI = GetObject("WinMgmts:")
    Set objs = WMI.InstancesOf("Win32_BaseBoard")
    For Each obj In objs
    sAns = sAns & obj.SerialNumber
    If sAns < objs.Count Then sAns = sAns & ","
    Next
    MBSerialNumber = sAns
    End Function


    I get such error message:
    automation error
    The system cannot find the file specified

    Referring to
    For Each obj In objs in the cod
    Hopping that helps for better understanding the problem

  4. #4
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: How make WMI works with xp+sp3 and Vista?

    try this one
    vb Code:
    1. Set WMIObjectSet = GetObject("winmgmts:\\.\root\CIMV2").ExecQuery("SELECT * FROM Win32_BaseBoard")
    2. For Each WMIObject In WMIObjectSet
    3.     outstr = outstr & WMIObject.SystemProperties_("__CLASS")
    4.     For Each WMIProperty In WMIObject.Properties_
    5.         outstr = outstr & vbNewLine & WMIProperty.Name & " = "
    6.         outstr = outstr & WMIProperty.Value & vbNullString
    7.     Next
    8.     outstr = outstr & vbNewLine
    9. Next
    10. Debug.Print outstr
    11. Set WMIObjectSet = Nothing
    or see http://www.winscripter.com/WSH/WMI/114.aspx for impersonation levels
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Feb 2007
    Posts
    18

    Re: How make WMI works with xp+sp3 and Vista?

    westconn1: Thank you for the code you send but unfortunatly it didn't help as the same arror nesaage appeared at second item of the code, namely:
    westconn1: Thank you for the code you send but unfortunately it didn't help as the same error message appeared referring to the second item of the code, namely:
    For Each WmiObject In WMIObjectSet
    Hopping someone can find a solution to this strange problem

  6. #6
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: How make WMI works with xp+sp3 and Vista?

    i tested the same code in vista without problem

    vista home premium

    try using impersonate
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Feb 2007
    Posts
    18

    Re: How make WMI works with xp+sp3 and Vista?

    Westconn1: Thank you a lot for the clarification, probably the code you mentioned will work perfectly on Vista. The problem is that all cods calling for WMI are not working on my friend’s computer with XP-Sp3 system installed. I wish if I know how to use impersonate. Honestly, I have never heard of it yet. Very much obliged for your suggestion and any suggestion from anyone.

  8. #8

    Thread Starter
    Junior Member
    Join Date
    Feb 2007
    Posts
    18

    Re: How make WMI works with xp+sp3 and Vista?

    Here is an article confirms that the problems are not with the codes sent but with XpSp-3 itself probably WMI operations are among the ones effected. The question is how to overcome such problems n order to make VB6 works smoothly with this monster?
    http://community.contractwebdevelopm...p-sp3-problems

  9. #9
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: How make WMI works with xp+sp3 and Vista?

    to use impersonate
    try like
    vb Code:
    1. Set WMIObjectSet = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\CIMV2").ExecQuery("SELECT * FROM Win32_BaseBoard")
    i will see if i can test on sp3 later
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  10. #10

    Thread Starter
    Junior Member
    Join Date
    Feb 2007
    Posts
    18

    Re: How make WMI works with xp+sp3 and Vista?

    Great thank for your care, unfortunately it did not work.

Posting Permissions

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



Click Here to Expand Forum to Full Width