O'Reilly logo

Microsoft® Windows® Scripting Self-Paced Learning Guide by Ed Wilson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Moving Past Lame Arrays

I will admit the previous script was pretty lame. But because the construction of an array is very finicky, I wanted you to have a reference for the basic array (you will need it for your labs).

In the next script (ArrayReadTxtFile.vbs), you open up a text file, parse it line by line, and write the results into an array. You can use this line-parsing tactic later as a way to feed information into a more useful script. Right now, all you’re doing with the array after it is built is echoing its contents out to the screen.

Option Explicit On Error Resume Next Dim objFSO Dim objTextFile Dim arrServiceList Dim strNextLine Dim i Dim TxtFile Const ForReading = 1 TxtFile = "c\scripts\ServersAndServices.txt" Set objFSO = CreateObject("Scripting.FileSystemObject") ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required