Using Robocopy or xcopy to Copy Files to Multiple Computers

deploy_256There are a couple commands you can use to copy files to multiple computers, Robocopy and xcopy. Many users find Robocopy to be more efficient, but I’ll go over both xcopy and Robocopy and some of the errors you might come across when deploying the command and how to resolve them.


Using xcopy

Copy files to multiple computers by creating a command step in PDQ Deploy. An example of the command step to copy the files is below. The first path specified is the origin of the file, and the second path specifies where you want the files to be copied to.

xcopy /E /I /Y "\\TOKEN\Deploy\Student Tests" "%PUBLIC%\Desktop\Tests"

/I=if directory doesn’t exist it will be created in the target machine

/E=copy all directories even if empty

/Y=to answer yes if any of the files in the target need to be overwritten.

Place the paths in double-quotes. This is necessary if there are spaces in your path, and just good practice even if there aren’t any spaces.

When copying files, some PDQ Deploy users find their deployment returns an error code four. Avoid an error code four by going into package properties and making sure that your Run as is set to Deploy User and not Local System. If you run it as a local system it will not be able to access remote resources and will return Error Code 4.

Remember, the computer you’re deploying from has to be able to access the network share. Use a UNC path, not a mapped drive. Mapped drives require more steps, trust me you do not want to do that extra work.

What about Robocopy?

Robocopy is hit and miss available XP, but Vista on up Windows computers will have Robocopy. An example of a command step to copy the files using Robocopy is below. The first path specified, is the origin of the file, and the second path specifies where you want the files to be copied to.

robocopy.exe "\TOKEN\Deploy\Student Tests" "%PUBLIC%\Desktop\Tests" /MIR

/MIR=mirror, which is Robocopy’s parameter for making the target look just like the source.

Below the command field is where success codes are entered. You need to add a “1” into this field. In Robocopy, both 0 and 1 mean success. If you do not put a “1” into this field, the files will still successfully copy but it will return as an error code.

Note: The variable %PUBLIC% will not work for XP Machines. If you have the misfortune of having XP machines in your environment, you can create a second command step, and under “Conditions” select only XP and instead use the variable %ALLUSERSPROFILE% to copy out files to the XP machines as well.