|
-
Oct 28th, 2009, 09:05 AM
#1
Thread Starter
Junior Member
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?
-
Oct 28th, 2009, 03:37 PM
#2
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
-
Oct 29th, 2009, 02:41 AM
#3
Thread Starter
Junior Member
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
-
Oct 29th, 2009, 05:12 AM
#4
Re: How make WMI works with xp+sp3 and Vista?
try this one
vb Code:
Set WMIObjectSet = GetObject("winmgmts:\\.\root\CIMV2").ExecQuery("SELECT * FROM Win32_BaseBoard") For Each WMIObject In WMIObjectSet outstr = outstr & WMIObject.SystemProperties_("__CLASS") For Each WMIProperty In WMIObject.Properties_ outstr = outstr & vbNewLine & WMIProperty.Name & " = " outstr = outstr & WMIProperty.Value & vbNullString Next outstr = outstr & vbNewLine Next Debug.Print outstr 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
-
Oct 29th, 2009, 08:31 AM
#5
Thread Starter
Junior Member
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
-
Oct 29th, 2009, 04:05 PM
#6
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
-
Oct 30th, 2009, 06:57 AM
#7
Thread Starter
Junior Member
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.
-
Oct 30th, 2009, 07:21 AM
#8
Thread Starter
Junior Member
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
-
Oct 30th, 2009, 04:04 PM
#9
Re: How make WMI works with xp+sp3 and Vista?
to use impersonate
try like
vb Code:
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
-
Oct 30th, 2009, 04:21 PM
#10
Thread Starter
Junior Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|