er22 Posted April 25, 2013 Posted April 25, 2013 Need some help writing a script to copy a folder (with sub contents) to multiple remote machines. i have done it for files but how do you to it for folders help!! @Rem simple copy script for Windows Command Interpreter (cmd.exe) @echo Read in each hostname entry in the file hostnames.txt amd copy the local file to the c$ of each hostname FOR /F %%i in (hostnames.txt) do copy name.bmp \\%%i\"c$\Program Files\"
X-13 Posted April 25, 2013 Posted April 25, 2013 If you have access to the server, you could do this with Group policy. Computer Preferances > files [i think] Put the source folder [on a shared drive] as \\server\share\folder\* and set the target as "%programFiles%\", I also usually set it as "apply once".
er22 Posted April 25, 2013 Author Posted April 25, 2013 i was trying to use cmd instead getting the names from a txt file for the machines, then copy the folder to c:\Windows\System32\oobe somethng like this ( its wrong at the moment) FOR /F %%D in (hostnames.txt) do Xcopy /E / Y "c:\Info*.*" "c$\Windows\System32\oobe\" \\%%D i know you can to it like this Xcopy /E /Y "c:\MyProject\Sample*.*" "\Computer1\Sample\" Xcopy /E /Y "c:\MyProject\Sample*.*" "\Computer2\Sample\" Xcopy /E /Y "c:\MyProject\Sample*.*" "\Computer3\Sample\" Xcopy /E /Y "c:\MyProject\Sample*.*" "\Computer4\Sample\" but that will take to long, need it to get the names from a text file.
X-13 Posted April 25, 2013 Posted April 25, 2013 If you run it in CMD what happens? Are there any error messages? I'm guessing it's a startup script, where is the source file located? If you change "C:\Windows\System32\oobe\" to "%windir%\system32\oobe\" does it work?
mukz Posted April 25, 2013 Posted April 25, 2013 do you have remote ranger or anything like that? you may be able to use that without the use of scripts
er22 Posted April 25, 2013 Author Posted April 25, 2013 (edited) no i dont i would like to write a script that way i can use it for other things Edited April 25, 2013 by er22
er22 Posted April 25, 2013 Author Posted April 25, 2013 its working FOR /F %%D in (hostnames.txt) do Xcopy /E /Y "c:\files\*" "\\%%D\c$\Windows\System32\oobe\"
Tall_Paul Posted April 25, 2013 Posted April 25, 2013 Take a look at Robocopy. Superb for situations like this.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now