?
Solved

using list in vbs

Posted on 2014-10-31
7
Medium Priority
?
216 Views
Last Modified: 2014-10-31
I got the following script from a different question on EE, which shows the version of internet explorer on the computer you run the script on. If I change strComputer = "." to strComputer = "remotecomputername" it works great to show the version on a remote pc as well.

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)

it works great, but now I would like to use a list of computers and have the script run on each computer name in the list, then output the results to a file, so that is would have something like,

computer1 = ie8
computer2 = ie10

I have been googleing this but I think I'm too new to scripting, and haven't been able to figure it out. So would this be hard to do, meaning it isn't just adding a few more lines to the script.
0
Comment
Question by:JeffBeall
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 35

Assisted Solution

by:ste5an
ste5an earned 80 total points
ID: 40416331
Please define "list".
0
 
LVL 1

Author Comment

by:JeffBeall
ID: 40416352
well, I have a list of computers I need to know the version of IE that is installed on them. I could make it a text document, an excel document, or whatever would work. I just thought it would be something like

computer1
computer2
computer3

and so on.
0
 
LVL 67

Assisted Solution

by:sirbounty
sirbounty earned 960 total points
ID: 40416389
Try this...
Const HKEY_LOCAL_MACHINE = &H80000002

Dim objFSO : Set objFSO = CreateObject

("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("c:\PCs.txt")
Set objOut = objFSO.CreateTextFile("C:\PC_IEVer.txt")

Do while not objFile.AtEndOfStream
  strComputer = objFile.ReadLine
  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
  objOut.WriteLine "Installed IE Version on " & strComputer & ": " & strValue & VBCRLF & "IE Version: " & Left(strValue,1)
Loop

objFile.Close
objOut.Close

Open in new window

0
Give Your Engineering Team a Productivity Boost

Learn why container technology is so powerful and how it can provide your team with productivity gains and other benefits.

 
LVL 1

Author Comment

by:JeffBeall
ID: 40416473
thank you sirbounty, however, two things about this.
1st, our policies at work don't allow me to create files directly on C, so I changed
Set objFile = objFSO.OpenTextFile("c:\pcs\PCs.txt")
to
Set objFile = objFSO.OpenTextFile("c:\pcs\pcs\PCs.txt")
and created a folder call pcs on the root of C. So if that is okay, then the other thing is, when I run the script it errors with

Script: C:\users\d01jbeaje02\Desktop\IEVersion2.vbs
Line:     5
Char:    1
Error:    Expected Statement
Code:    800A0400
Source:  Microsoft VBScript compilation error

any ideas why this is happening?
0
 
LVL 34

Accepted Solution

by:
it_saige earned 960 total points
ID: 40416481
Somehow in sirbounty's copy/paste flurry, the scripting object parameters got separated from the declaration.

With your changes and a combining line 3 and line 5
Const HKEY_LOCAL_MACHINE = &H80000002

Dim objFSO : Set objFSO = CreateObject("Scripting.FileSystemObject")

Set objFile = objFSO.OpenTextFile("c:\pcs\PCs.txt")
Set objOut = objFSO.CreateTextFile("C:\pcs\PC_IEVer.txt")

Do while not objFile.AtEndOfStream
  strComputer = objFile.ReadLine
  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
  objOut.WriteLine "Installed IE Version on " & strComputer & ": " & strValue & VBCRLF & "IE Version: " & Left(strValue,1)
Loop

objFile.Close
objOut.Close

Open in new window


-saige-
0
 
LVL 1

Author Closing Comment

by:JeffBeall
ID: 40416514
Wow! you guys are good! I wish I knew how to script. It's hard to be new and see how far I have to go.
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 40416791
Thanks saige for the pickup.
JeffBeall, it will come - stay with it, we all start from the same place. ;^)
0

Featured Post

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Suggested Courses

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question