westone
asked on
Batch file question
Hi,
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$\wi ndows\syst em32
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.
Thanks,
Bill
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$\wi
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.
Thanks,
Bill
ASKER
'This pings the computer before attempting to change the password. If the computer is not reachable, it is skipped.
What password does this script change? I am logged in as Administrator on DC, and only targeting computers in this domain. I have access to all the drives without resetting passwords, and prefer not to change any.
What password does this script change? I am logged in as Administrator on DC, and only targeting computers in this domain. I have access to all the drives without resetting passwords, and prefer not to change any.
I'm sorry about that. It does NOT change any passwords. Those comments are incorrect.
(I copied the ping function from a previous script and it had those comments).
It just pings the computer name. If the computer doesn't respond, it will skip to the next section. It should say, 'This pings the computer before attempting to copy the file. You can change the comments, but they are safe to ignore.
(I copied the ping function from a previous script and it had those comments).
It just pings the computer name. If the computer doesn't respond, it will skip to the next section. It should say, 'This pings the computer before attempting to copy the file. You can change the comments, but they are safe to ignore.
ASKER
Okay, I have used a vb script to change passwords on a remote computer before, and I didn't think I saw any code that looked like it was doing that. Give me some time and I'll get back to you.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Shift-3's solution answered the specific question I asked. Cybersean's solution is more sophisticated, but with Shift-3's solution I have already been able to copy Scheduled Tasks and run maintenance tasks on all the machines on this network. Plus it has the added advantage of being able to be used on workgroups and LANs with no domain just as easily, and I look after a number of those as well. Since Cybersean's script retrieves the list of computers from AD it is restricted to domain use.
Thanks for the help.
Thanks for the help.
Open in new window