Computer Hope
Software => Computer programming => Topic started by: LAIN1987 on January 05, 2017, 08:28:33 PM
-
Hello,
I am new at creating batch files and am having a bit of trouble. what i am trying to do is build a batch that will basically copy the contents of 3 different files and paste them to a location on my network. i have come up with a CMD line code that will do the job but when i attempt to build this into a batch file it fails on my command. my code i am trying to use is as follows.
for /f %H in (hostnames.txt) do @robocopy /COPYALL /E "\\source" "\\%H\c$\destination"
i want this code to run 3 times copying 3 different files to 3 different locations from 3 different locations. any help would be appreciated. if you need more info feel free to ask.
-
In a batch script, you need 2 percent signs in FOR variables, but only one at the prompt. So change %H to %%H.
-
Thanks for the help on that, one more question i added the extra % and that seemed to work baring the attached image. basicaly CMD is showing that the destination is not found. when i run the command outside of the batch file it runs fine. any ideas?
[attachment deleted by admin to conserve space]
-
Maybe run the batch as administrator?
Also check that the folders shown actually exist
-
location does exist as i am able to push these files using just the solo command outside of the batch file. as for admin attempted while logged in as admin on system still no go just getting the error inside the image provided. my goal here is to basically push 3 folders/files to a group of pc's on a network streamlining the process so i dont need to move the files/folders manualy if that gives any insight to aid in this endeavor
-
Looking at your screenshot I can see plain as day that you did not double BOTH of the percent symbols.
-
Me too.