Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

WMI ???

Status
Not open for further replies.

country73

Technical User
Jan 17, 2003
59
US
What are the requirements for running a WMI Script?
I'm running this script on two different machines, one W2K the other XPSP2_Pro.
Everything runs fine on XP machine, but not on W2K
When running the simple script from MSDN -
Dim wmiColl, wmiObj
Dim strComputer
strcomputer = "."
Set wmiColl = GetObject("WinMgmts:\\" & strComputer & "/root/cimv2").ExecQuery("Select * FROM Win32_NTEventlogFile")

For Each wmiObj In wmiColl
WScript.Echo wmiObj.LogfileName
Next
I keep getting an error on "Set wmiColl"
Any ideas as to what needs to be installed to run these scripts??
 
Well, you need to have WMI installed as a start. Is it installed on the 2K machine?

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
And you may have to replace this:
& "/root/cimv2").
By this:
& "\root\cimv2").

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
TomThumbKP,
Yes, WMI is installed on the W2K machine.

PHV,
Why would I need to change that line when it works fine on the XP machine? (I tried it, and same results, I'm just curious as to why you think it would need to be different.)
 
>I keep getting an error on "Set wmiColl"
what error?
 
Sorry for not getting back to you earlier...

I get an error referencing 0x80041013, it says the error is on the Set wmiColl line.
 
>on the Set wmiColl line
Try separate the line into two: one binding to root\cimv2, one for execquery see which one fails.
 
strcomputer = "."
Set wmiColl = GetObject("WinMgmts:\\" & strComputer & "/root/cimv2")
wmiColl.ExecQuery("Select * FROM Win32_NTEventlogFile")

For Each wmiObj In wmiColl
WScript.Echo wmiObj.LogfileName
Next

Line: 5
Char: 1
Error: Object doesn't support this property or method
Code: 800A01B6

This is the "For Each wmiObj In wmiColl" line
I get this error message on both the W2K machine & XP (which it was working fine on the first time)
 
Set x = wmiColl.ExecQuery("Select * FROM Win32_NTEventlogFile")
For Each wmiObj In x

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
No..., like this.
[tt]set svc = GetObject("WinMgmts:\\" & strComputer & "\root\cimv2")
set wmiColl=svc.ExecQuery("Select * FROM Win32_NTEventlogFile")
[/tt]
 
My post addressed to country73. The traffic is a bit slow right now. I may stay out for a while.
 
Kicking myself now...
I believe I need to go get another cup of coffee this morning.

Thanks a lot for the help on this.

I'm still kind of curious though. I pulled that small script from the MSDN website, so why does it work on XP but needs to be modified to work on W2K?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top