VBScript to copy files from a remote windows xp profile to a remote Windows 7 profile

Hello

I am trying to write some code that will let me input two computers names a username and will copy the my documents folder from one computer to another.

This is my first attempt Im not a good vbscript write but i have written some useful ones,

Any help on this would be great

Thanks in advance
strComputer1 = InputBox("What is the name of the computer your copying from? include \\", "Computer1")
strComputer2 = InputBox("What is the name of the computer your copying to? include \\", "Computer2")
strUsername = InputBox("What is the Users Name of the files you are copying over?", "Username")

strC1 = strComputer1 & "\C$\Documents and Settings\" & strUsername 

strC2 = strComputer2 & "\C$\users" & strUsername
 
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.CopyFolder strC1 & "\My Documents", strC2 & "\Documents", True

Open in new window

LVL 10
augwestDirector of Information TechnologyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

merowingerCommented:
please try this one
Set objFSO = CreateObject("Scripting.FileSystemObject") 

strSource = InputBox("What is the name of the computer your copying from?") 
strTarget = InputBox("What is the name of the computer your copying to?") 
strUsername = InputBox("What is the Users Name of the files you are copying over?") 
 
strSourceFolder = chr(34) &"\\" &strSource & "\C$\Documents and Settings\" & strUsername &"\My Documents" &chr(34)
strTargetFolder = chr(34) &"\\" &strTarget & "\C$\users\" & strUsername &"\Documents" &chr(34)
  

objFSO.CopyFolder strSourceFolder, strTargetFolder, True

Open in new window

0
augwestDirector of Information TechnologyAuthor Commented:
I get the folloing error
Line 11
Char 1
Bad File name or number
code 800A0034
Source Microsoft VBScript runtime error
0
merowingerCommented:
whats about this?
set objShell = CreateObject("Wscript.Shell")

strSource = InputBox("What is the name of the computer your copying from?") 
strTarget = InputBox("What is the name of the computer your copying to?") 
strUsername = InputBox("What is the Users Name of the files you are copying over?") 
 
strSourceFolder = chr(34) &"\\" &strSource & "\C$\Documents and Settings\" & strUsername &"\My Documents\*.*" &chr(34)
strTargetFolder = chr(34) &"\\" &strTarget & "\C$\users\" & strUsername &"\Documents\*.*" &chr(34)
  

objShell.Run "xcopy " &strSourceFolder &" " &strTargetFolder &" /E",0,true

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Newly released Acronis True Image 2019

In announcing the release of the 15th Anniversary Edition of Acronis True Image 2019, the company revealed that its artificial intelligence-based anti-ransomware technology – stopped more than 200,000 ransomware attacks on 150,000 customers last year.

augwestDirector of Information TechnologyAuthor Commented:
Seemed to knock the error out,

One quick question if i need to add another folder to copy would i just add it after like this?

Or should i make a seperate vbs?
0
augwestDirector of Information TechnologyAuthor Commented:

set objShell = CreateObject("Wscript.Shell")

strSource = InputBox("What is the name of the computer your copying from?") 
strTarget = InputBox("What is the name of the computer your copying to?") 
strUsername = InputBox("What is the Users Name of the files you are copying over?") 
 
strSourceFolder = chr(34) &"\\" &strSource & "\C$\Documents and Settings\" & strUsername &"\My Documents\*.*" &chr(34)
strTargetFolder = chr(34) &"\\" &strTarget & "\C$\users\" & strUsername &"\Documents\*.*" &chr(34)
  

objShell.Run "xcopy " &strSourceFolder &" " &strTargetFolder &" /E",0,true

strSourceFolder1 = chr(34) &"\\" &strSource & "\D$\*.*" &chr(34)
strTargetFolder2 = chr(34) &"\\" &strTarget & "\D$\*.*" &chr(34)
  

objShell.Run "xcopy " &strSourceFolder1 &" " &strTargetFolder2 &" /E",0,true

Open in new window

0
augwestDirector of Information TechnologyAuthor Commented:
also would there be anyway to add a progress bar to something like this?
0
augwestDirector of Information TechnologyAuthor Commented:
Also this seems to time out and not get all the folders any suggestions?
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.