Light Mode Dark Mode
May 23, 20121 min read

Copying Files to Clients Using ConfigMgr

AdobeStock_256229414 1

This seemingly simple task stumps and trips up a lot of people in both ConfigMgr 2007 and ConfigMgr 2012. It’s not that it’s a difficult task per se, it’s that people go into it with bad assumptions.

The main bad assumption has to do with the current working directory. In general, the current working directory of a program in ConfigMgr is the folder containing the package files whether that be cached locally or on the DP based on where the program is run from. You should never count on it being in one place and thus you should never hard-code a path in. Using a batch file though, you can use the %~dp0 batch file parameter within the batch file itself to refer to the directory the batch file is run from.

The very simple solution presented here can of course be expanded upon and customized but is flexible enough to be just dropped in without any real customization.

1. Create a parent folder in your source file repository.

Deploy the program to the desired systems

2. Create a sub-folder in the folder just created called Files2Copy and place the files you are going to copy in this folder.

3. Create a batch file called filecopy.bat with the below two lines and place it in the parent directory created in step 1. This batch file will create a folder specified on the command-line (if it doesn’t already exist) and copy the files from the Files2Copy folder into it.

if not exist “%1” md “%1”

copy /y “%~dp0Files2Copy*.*” “%1”

4. Create a package using the parent directory created in step 1 as the source file location.

Create a package using the parent directory

5. Create a program and set the command line to filecopy.bat c:DesktopTools. Note that although my source directory and destination directory are both named “Desktop Tools”, this was just a convenient naming standard I adopted for this example and does not have to be the case.  Create a program and set the command line to filecopy.bat c:DesktopTools

6. Advertise/Deploy the program to the desired systems.

Create a parent folder in source file repository

Done.

You can of course modify this very simple batch file to do some more complex things or use xcopy (http://technet.microsoft.com/en-us/library/bb491035.aspx) to perform advanced filtering and selective copying of files and sub-folders.

AdobeStock_488605053

Ready to Get Started?

Schedule a one-on-one demo today.

Request a Demo