Robocopy and Task Sequence

Robocopy and Task Sequence
5 (100%) 3 votes

Hi all,

Sometimes we need copy files from the server to the client during OS deployment, but if you’re a large organization with many physical locations, copying files from a specific location may not be suitable as it may cause copying files from the WAN link.

Due this, people of use DFS or use SCCM to do it creating CMD files to run as a program and execute this via TS.

This is an interesting way to do, but i always try to avoid creating CMD files (I prefer use VBS to Powershell), and the reason is simple….it is another script that people need to know and need to maintain. In this world where people start early using computers, creating CMD file and maintain a CMD file may not be as simples as it was when I started..anyway…

As i said, i like to avoid creating scripts and as I only want to copy files from the server to the client during the OS deployment, let’s use the robocopy. but it is not as easy as it looks…

1- we don’t want to use the wan link…let’s create a package (yes, package not application). as we’re going to create a package, we don’t need only have files, we can have folders and files (including empty folders)
2- add the package to a dp or dp group
3- on your task sequence, create a TS Variable and add the PKDID as value (this is necessary as your TS does not have a variable for it, at least as far as i know off). I called it RFLUtils_PkgID RFLUtils_PkgID
4- on your partitioning, confirm that you have a variable for the C drive. I’m using OSDisk here
5- after apply OS add “run command line step” and add the following code

robocopy.exe %_SMSTSMDataPath%\Packages\%RFLUtils_PkgID% %OSDisk%\ /e /copy:DATA /r:1 /w:1 /b /xj /xjd /xjf /log:%OSDisk%\Windows\temp\rflutils.log

The %_SMSTSMDataPath% will be converted to the pack where the package is downloaded (ie: C:\_SMSTaskSequence)
the %RFLUtils_PkgID% will be converted to the package ID (ie: 00100001)
the %OSDisk% will be converted to the drive (ie. C:\)

when the task sequence runs, the command will be converted to something like should be like

robocopy.exe C:\_SMSTaskSequence\Packages\RFL0001F C:\ /e /copy:DATA /r:1 /w:1 /b /xj /xjd /xjf /log:C:\Windows\temp\rflutils.log

6- select the package checkbox and select the package. it will make the TS download the files from the nearest DP
7- On the options select continue on error or use the following success codes: 0 3010 1 2 3 4 5 6 7 8 16
8- you are good to go

to know more about the success code, check this link

note that the error 16 is not listed but it means “Robocopy did not copy any files.  Check the command line parameters and verify that Robocopy has enough rights to write to the destination folder.”


Comments are closed.
%d bloggers like this: