visual basic script

I am about as new to scripting as you can get, however, I am encouraged that I think I can follow pretty well what a script is trying to do. So I found the follow script which is supposed to get the version of IE it reads as follows.

strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & _
    "\root\cimv2\Applications\MicrosoftIE")

Set colIESettings = objWMIService.ExecQuery _
    ("Select * from MicrosoftIE_Summary")

For Each strIESetting in colIESettings
    Wscript.Echo strIESetting.Version
Next

So I think what is happening is, the first line sets the variable strComputer, then objWMIService is set using the command GetObject from the path \\computername\root\cim2\Application\MicrosoftIE
Then colIESettings is set to everything gathered from MicroSoftIE_Summary
lastly each thing is displayed from StrIESetting.Version

If that is correct, I don't understand why when I run the script on my PC I get a Windows Script Host error at
line 2, Char 1 error 0x8004100E code 8004100E Source (null)
Any ideas what I am doing wrong?
LVL 1
JeffBeallAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

omgangIT ManagerCommented:
Apparently the namespace \root\cimv2\applications\microsoftie_summary was removed in Windows Vista and later.  That's why it's not working on your Windows 7 machine.
OM Gang
0
omgangIT ManagerCommented:
See this PAQ for a sample of a script that you can use to get IE version.
http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_26761987.html

OM Gang
0
it_saigeDeveloperCommented:
You are getting this error because Microsoft removed the MicrosoftIE namespace from the WMI namespaces starting with Windows Vista.

So instead we have to settle for querying the registry:
Const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
strKeyPath = "SOFTWARE\Microsoft\Internet Explorer"
strValueName = "Version"
oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
Wscript.Echo "Installed IE Version: " & strValue & VBCRLF & "IE Version: " & Left(strValue,1)

Open in new window


-saige-
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

JeffBeallAuthor Commented:
a-ha, so that's want is going on! I have two more questions then, first, because this happened, I was wondering, is there a way to list what is in the WMI namespace?
and 2nd does strComputer= "." mean it is looking on the computer that the script is running on? if so, would I be able to have this run on a remote computer using something like
strComputer="remotecomputername"
also - just to be sure I'm on the right page, strComputer is just a variable, correct? I could use
bob="."
if I wanted to. Not that I would, just making sure I have this correct.
0
omgangIT ManagerCommented:
Not sure about enumerating the WMI namespace.

Yes, strComputer="." means the local machine.

Yes, it's possible to run the script against another machine by changing the value assigned to strComputer.

Yes, strComputer is variable and could be replaced by almost anything.  By convention, many choose to preface variables with the intended data type, e.g. strComputer for a String data type variable, intCounter for an integer type variable, etc.  It helps when reading code.  In vbscript, however, all variables are actually Variant data types so it's possible for strComputer to get assigned a value of 297.

OM Gang
0
it_saigeDeveloperCommented:
Yes you can list what is in the WMI namespace.
' List All WMI Namespaces

strComputer = "."
Call EnumNameSpaces("root")
 
Sub EnumNameSpaces(strNameSpace)
    WScript.Echo strNameSpace
    Set objWMIService=GetObject _
        ("winmgmts:{impersonationLevel=impersonate}\\" & _ 
            strComputer & "\" & strNameSpace)

    Set colNameSpaces = objWMIService.InstancesOf("__NAMESPACE")

    For Each objNameSpace In colNameSpaces
        Call EnumNameSpaces(strNameSpace & "\" & objNameSpace.Name)
    Next
End Sub

Open in new window


Yes, strComputer is a variable (you could use bob).
Yes, the value for strComputer, ".", refers to the local computer.  It's the same as using:
Set objWMIService = GetObject("winmgmts:\\.\root\cimv2\Applications\MicrosoftIE")

Open in new window


For running on a remote computer you would have to use the remote computer name as you indicated.

-saige-
0
it_saigeDeveloperCommented:
Ofcourse a better version of the above script does not use seperate echo's for each namespace:
' List All WMI Namespaces


strComputer = "."
strNamespaces = EnumNameSpaces("root")
wscript.echo strNamespaces
 
Function EnumNameSpaces(strNameSpace)
	EnumNameSpaces = EnumNameSpaces & strNamespace & VBCRLF
	Set objWMIService=GetObject _
		("winmgmts:{impersonationLevel=impersonate}\\" & _ 
		strComputer & "\" & strNameSpace)

	Set colNameSpaces = objWMIService.InstancesOf("__NAMESPACE")

	For Each objNameSpace In colNameSpaces
		EnumNameSpaces = EnumNameSpaces & EnumNameSpaces(strNameSpace & "\" & objNameSpace.Name)
	Next
End Function

Open in new window


-saige-
0
JeffBeallAuthor Commented:
awsome, thanks for the namespace thing. you must really know scripting. some day i hope to be able to write my own scripts.
now I just have to try and have the script that shows the IE version output the versions of IE from a list of computers. but I think that's outside this question.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VB Script

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.