Solved

using list in vbs

Posted on 2014-10-31
7
214 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 34

Assisted Solution

by:ste5an
ste5an earned 20 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 240 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
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 
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 240 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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

696 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