Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am trying to create a batch file to create a network folder based on computer name and then copy the desktop, My Documents, Favorites from each profile to that share. So destination should be something like this: \\server\share\computername\profile name\Mydocuments, etc.

I can create the computername dir. but nothing copies. I have tried this....

@echo off
md \\servername\sharename\profile backups\%computername%
cd C:\Documents and Settings
xCopy "\%%\Desktop" \\servername\sharename\profile backups\%computername% "%computername%\%%\*.*" 

I have tried a few different methods but can never get them to copy to the share.. it needs to read the variable computername so i dont have to manually type it. Please help

share|improve this question
    
I also need it t read the variable userprofile name –  Layton Jun 13 '13 at 17:54

1 Answer 1

You seem to be missing some variable names.

In the code supplied: Replace the first %% with %homepath%, and replace the second one with %username%

Since %homepath% includes the "C:\documents and settings\" part, you don't need to change to that directory first.

Also encapsulate any paths that contain spaces (or potentially contain spaces) with quotes.

Lastly, consider using use XCopy's switches to copy the assigned permissions as well.

@echo off
md "\\servername\sharename\profile backups\%computername%"
xcopy "\%homepath%\Desktop" \\servername\sharename\profile backups\%computername% "%computername%\%username%\" /O /X /E /H /K
share|improve this answer
    
Okay that helped however I need the script to copy and create each profile dir. The %username% argument only copies the logged on user. –  Layton Jun 13 '13 at 18:46
    
Then you'll need to expand the script to include a loop, which iterates though a list of profiles. Getting that list can also be scripted by taking the info from a directory listing which contains all the profiles. Based on that, you'd probably be better off aiming to do this in PowerShell (or VBS). –  Ƭᴇcʜιᴇ007 Jun 13 '13 at 20:28

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.