Batch file question
Posted on 2008-11-06
I am fairly familiar with using batch files to automate simple tasks, and use them often in conjuction with Scheduled Tasks to automate tasks that otherwise are not able to be scheduled. What I would like to do is find out if it is possible to write a batch file or script to loop through a command or series of commands, and use a variable which is replaced by the name of a computer on my network. So I could create a list of computer names on my network, then run the script and have the script reference the list of computer names, and loop through whatever commands are in the script applying each name to the variable.
For example, if I wanted to copy a particular file from the server to the System32 folder on each client, the script might contain the command: copy filename \\remotecomputername\c$\windows\system32
How can I write it to loop and replace remotecomputername with a name from my list of computers? I realize for this example I could just use a logon script, but that is not the point. I want to learn how to use a variable list in a script.