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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

read input file

Status
Not open for further replies.

grabrail

Technical User
Aug 15, 2001
269
GB
Hi

I need my vb script to be able to read a txt file that contains a list of servers, it should take the first name in the list apply it to a variable, run some commands (which i have in place already) then loop round and then read the second name, etc, etc, until there is no names left in the file then finish.

Anyone know how I can achieve this.

Cheers
J
 
i think this is what you need:

dim filesys, text, readfile, contents, filetoread, wshshell
i = 0
set wshShell = WScript.CreateObject("WScript.Shell")

set filesys = CreateObject("Scripting.FileSystemObject")
filetoread = "c:\my_folder\my_file.txt"
set readfile = filesys.OpenTextFile(filetoread, 1)
do while readfile.AtEndofStream <> true

each_line = readfile.Readline

loop
'''''you can parse each_line and get your data.
msgbox each_line
readfile.close
 
Cheers that did the trick barny2006

much appreciated
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top