copy profile to network share

I am migrating my users to new computers (50+ users) and I would like them to run a batch file that will copy their user profile to their home directory (P:).  Below are the contents of my batch file, which removes temporary internet files and then copies the rest to the P:\profile directory.  

rd "C:\Documents and Settings\%username%\Local Settings\Temporary Internet Files" /s /q
xcopy "C:\Documents and Settings\%username%" p:\profile\ /E /I /H /O /Y /C

This works fine as an administrator, or if I do these items by hand as a user these work, but running via the batch file it does not work.  I get an access denied, can't create p:\profile, and then can't find *.*

Any help would be great.

Who is Participating?
first of all make sure P:\Profile have share permissions and NTFS permissions set correctly.

Check that NTFS permissions is set to Domain users Read/Write/Modify.

Since you can do it with administrator, NTFS permissions could be the only thing stopping it from happening.
glennjbrownAuthor Commented:
This is the users home directory, and through windows they can do any tasks within the P:\ drive (R,W,X,D)

While you are logged in as administrator can you copy their profiles to a share that they can move them into their home drive from?  While the user is logged in the profile is being used and locked files can't be copied or moved.
You could setup a share with owner creator rights on your server.

Then change all the users accounts to be roaming accounts and set it to upload the users profiles to the profile share. Next time they log off it will do it automatically.

Exclude the Temporay internet files folder from within the local machine policy cause you dont need to upload that really.
Yes, files will be locked if user is logged on.

What you can do it to make a computer startup script.

This script will run with system rights, and can copy all the profiles to any network folder.

only problem is that username variable will not be set at this time.

You can use this command to extract the username from the folder list

dir /b | find /v "Administrator" | find /v "All Users" > profilename.txt

This will copy the names of all the user profiles in profilename.txt file.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.