Solved

robocopy experts

Posted on 2010-11-10
4
855 Views
Last Modified: 2012-08-13
I have a terminal server that has an application that we want to export on a regular basis.  A robocopy will work find on it, but the source is by default every user's document folder. I know there is a exclusion, but I do not want to write the source custom for every user that has a profile on the server (about 40 of them), and I also only need two specific folders in their Document folder.  It would also be handy because as people join the team, I do not want to have to also remember to add to this batch.

the folders in question are found in "c:\documents and settings\%username%\folder1" and "folder2".  I tried exclusions, but it wants the entire path to exclude, which is the same problem as the the inclusive batch, meaning I do not want to type out everyone's user names into this script nor modify it when new people join the team.


Any ideas?
0
Comment
Question by:tsaico
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 23

Expert Comment

by:Luciano Patrão
ID: 34107935
Hi

Here you can find robocopy commands and some examples. Also some other tools that can be use to copy/migrate folders/files

http://ss64.com/nt/robocopy.html

Jail
0
 
LVL 13

Expert Comment

by:rhinoceros
ID: 34109313
Good example: Use robocopy to copy the user profiles

More info:
http://ts.veranoest.net/ts_faq_profiles.htm
0
 
LVL 84

Accepted Solution

by:
oBdA earned 500 total points
ID: 34109583
The batch script (whatever.cmd) below will scan all user profiles for a given list of folders and copy those over to a defined target folder.
The script should work on W2k8/Vista/Win7 as well, the profile root is determined automatically.
It's currently in test mode and will only display the commands it would run in normal mode; remove the capitalized ECHO in front of "if exist" to run it for real.
@echo off
setlocal
:: *** The folder(s) to copy below the profile folder:
set FolderList="Folder 1" "Folder 2"
:: *** Path to the backup location:
set TargetRoot=D:\Temp
:: *** robocopy log file; %~dpn0 will expand to the script's path and name:
set LogFile=%~dpn0.log
:: *** Options for robocopy (except for source and target folder)
set RCOptions=/COPY:DAT /MIR /R:0 /W:0 /TEE /LOG+:"%LogFile%" /NP
:: *** No changes necessary below this line
if exist "%LogFile%" del "%LogFile%"
for /f "tokens=2*" %%a in ('reg query "HKLM\Software\Microsoft\Windows NT\CurrentVersion\ProfileList" /v "ProfilesDirectory" ^| find /i "ProfilesDirectory"') do call :expand ProfileRoot "%%b"
echo Profile root: %ProfileRoot%
for /d %%a in ("%ProfileRoot%\*.*") do (
  echo Processing %%~nxa ...
  for %%f in (%FolderList%) do (
    ECHO if exist "%%a\%%~f" robocopy.exe "%%a\%%~f" "%TargetRoot%\%%a\%%~f" %RCOptions%
  )
)
goto :eof

:expand
set %1=%~2

Open in new window

0
 
LVL 9

Author Closing Comment

by:tsaico
ID: 34113836
This is good, while it runs under a particular profile, I was hoping to run it under a scheduled task under my own, this will work.  THanks!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Migrating files on WS2003SP2 to Azure File Share 7 74
Shell script issue 4 66
Drive mapping problem 7 56
Active Directory Powershell Script 9 42
Recently, I had the need to build a standalone system to run a point-of-sale system. I’m running this on a low-voltage Atom processor, so I wanted a light-weight operating system, but still needed Windows. I chose to use Microsoft Windows Server 200…
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question