Ok , here is what I am wanting to do ultimately.

I have a script that runs windows internet explorer hot fix updates on a server that we have setup.
the script that we use here is this:

strComputer = inputbox("Enter station name to complete security update","Security Update")
if strComputer = "" then wscript.quit
on error goto 0
Set autoUpdateClient = CreateObject("Microsoft.Update.AutoUpdate",strComputer)
AutoUpdateClient.detectnow()
wscript.echo "Computer Updated."


this script is usually saved as a .vbs, in which at my company I have 2000 computers and a .txt file list of all the station names.
Now and then I get a 100 or some odd computer names on a .txt list that I have to manuall Copy the computer name, paste it into the input box of this script above, and then run the script.
So instead of allllll that.. I have descided that I want to make my application read the list of computers, take each computer name and write that computers name into the above script and then run the script. THE ONLY PROBLEM I am having is getting each computers name.

so this is what I need help from you experts and more experianced developers.


say this list is what is in a .txt file

sa08DATAPCd1
sa08DATAPC1d1
sa08DATAPC2d1
sa08DATAPC3d1
sa08DATAPCd41


so .. I need to read sa08DATAPCd1, then run that PC name into the above script that I gave.
Then the next computer sa08DATAPC1d1 would also get ran , and so forth on down the list.

I am having problems getting each station name stored for me to run the output on.

Please if anyone knows how I can get this done that would be great !

Recommended Answers

All 4 Replies

I'm pretty sure this works with vbs files. Use the filesystemobject, open the file and read it in.

Set objFs = CreateObject("Scripting.FileSystemObject")
Set objFile = objFs.OpenTextFile(yourfile)

Do While Not objFile.AtEndOfStream

strLine = objFile.ReadLine
' do what you want with the data

Loop

Ok .. *Update*

What I have done is pretty much wrote my console application to file output to a .txt file, and then saves it as a .vbs script.
It works so far that I can tell when it's ran.
The problem I encounter now, is where do I stream in the computers name to run the script on ?

as look below.

strComputer = inputbox("Enter station name to complete security update","Security Update")
if strComputer = "" then wscript.quit
on error goto 0
Set autoUpdateClient = CreateObject("Microsoft.Update.AutoUpdate",strComputer)
AutoUpdateClient.detectnow()
wscript.echo "Computer Updated."

if you take this code and save it as a .vbs you have in input box in which I put in the computers name from my network, and this invokes the update to that computer.
I have made my application write this whole script to a .txt file and then saved as a .vbs, but here is what I am wanting to do!

I want to stream in a computers name to this script, or edit this script if I must so that I can stream the computers name in, and have the update script ran on that computer.

For now thats what I am trying to accomplish.

Assuming you still have the text file with the computer names in it you need to use my bit of code in the .vbs file

Set objFs = CreateObject("Scripting.FileSystemObject")
Set objFile = objFs.OpenTextFile(yourfile)

Do While Not objFile.AtEndOfStream

    strComputer = objFile.ReadLine

    ' do what you want with the data
    on error goto 0
    Set autoUpdateClient = CreateObject("Microsoft.Update.AutoUpdate",strComputer)
    AutoUpdateClient.detectnow()
    wscript.echo "Computer " & strComputer & "  Updated."

Loop

Thanks it works like a charm !

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.