Kaseya Community

Copy a folder (not a file) from a UNC path

This question is answered

Admins of the world,

Is it possible to use the "Copy File - Use Credentials" command to copy a folder vs a file?  I need a scripted, non-batch file method of coping a folder from a  server.  I've tried slashes, asterisks, and the like.  No dice.

How should I copy a folder from a UNC path in an agent procedure.

Please let me know.


Thanks!

Verified Answer
  • You could use XCOPY with the /E switch: www.computerhope.com/.../ch000838.htm

    1. Create a step for "Use Agent Credential" and ensure that the agent credential has access to your UNC path.

    2. Execute Shell Command as User:

    echo "d" | XCOPY /E "\\server\share\folder" "C:\some\destination\folder"

  • One word "ROBOCOPY" Smile

All Replies
  • You could use XCOPY with the /E switch: www.computerhope.com/.../ch000838.htm

    1. Create a step for "Use Agent Credential" and ensure that the agent credential has access to your UNC path.

    2. Execute Shell Command as User:

    echo "d" | XCOPY /E "\\server\share\folder" "C:\some\destination\folder"

  • One word "ROBOCOPY" Smile

  • agree with HardKnoX, robocopy is a reliable tool to copy/sync files/folders.

  • Thanks!  All great answers.  It ended up being a combination between the xcopy and robocopy for compatibility purposes.

    Thanks!

  • Just another suggestion that you might look into..aside from robocopy and xcopy, I also like unison.  I've used it a couple of times to have a good two way folder sync for roaming laptops, where it only copies changes in the files.  I like the fact that it's two way.  I basically have a script running once a day on a set of roaming laptops that checks to see if it can access the server, and if it can, then it does the two way sync between a folder on the laptop and a folder on the server.  

    The users know that if they have data they want backed up on the laptop, they should save it in that folder, and if I need to push a new version of a specific document out to all of the laptops I simply copy it into that folder on the server, and the next time they are in the office they get the new file.