Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

copy files in login script using username variable 2

Status
Not open for further replies.

volleyman

MIS
Jun 12, 2002
183
US
All,

I am attempting to create a script that will copy everything in My Documents from the local machine to a network share for that particular user.

I have tested xcopy, but I think its failing when I attempt to use the %username% variable in the file path. If that's not correct, does anyone know the correct format or maybe another tool that will allow me to do this?

My command looks like this:

xcopy "c:\documents and settings\%username%\My Documents" "U:\MyDocuments" /S/C/Q/Y/R/D/M


any suggestions would be appreciated.



Zane D.
Systems Admin
 
Wouldn't it just be easier to do this in a GPO? GPO has built in folder redirection, that I believe will copy stuff. Sure makes more sense to me based on what you've supplied.

Pat Richard MVP
Plan for performance, and capacity takes care of itself. Plan for capacity, and suffer poor performance.
 
actually, GPO folder redirection moves the whole folder so that if the machine is offline, say a laptop at home but not connected via VPN, My Documents becomes unavailable.

I'm totally open to any solution that will allow the My documents folder to be available locally for convenience but copied to a network location for backup purposes. I just kinda assumed some sort of login script my work nicely if the username variable would work.


Zane D.
Systems Admin
 
Syntax seems ok. I tried a test run. But I might try it this way:

U:
cd\MyDocuments
xcopy "c:\documents and settings\%username%\My Documents" /S/C/Q/Y/R/D/M

Also, what is with the "D" option, that should be D:followed by a date according to my xcopy options (date option). Drop the D - it is redundant with the M since M gets anything changed (archive bit set).

R.Sobelman
 
You can also do offline access to My Documents through GPO. It leaves a local copy on the machine and syncs them on logoff

Pat Richard MVP
Plan for performance, and capacity takes care of itself. Plan for capacity, and suffer poor performance.
 
You might want to take a look at robocopy. With robocopy you're able to only copy newer/changed files based on creation/last modified dates instead of just archive attributes. A challenge could be having robocopy available on the clients though...
 
we use a program called mirrorfolder (i believe theres alternative free programs) this syncronises with a setup loction of your choice for any folder and has multiple options like Raid mode. failing this whats wrong with maybe a roaming profile? i assume you are just doing this so that the users files are backed up?
 
you got it. all of our laptops are encrypted so we aren't too worried about local storage for security reasons. its mostly for backup purposes. We don't have a comprehensive management policy for a machines, so as of now users are allowed to store locally in My Documents.

I'm just looking for a quick and easy way to copy things for backup purposes

FYI, I added the xcopy line to my login script. It basically worked, but it prompted the users to choose F for file or D for directories to be copied. I need to work that out...

Zane D.
Systems Admin
 
try xcopy /E

/E Copies directories and subdirectories, including empty ones. Same as /S /E. May be used to modify /T.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top