Using xcopy in VB

First, Thanks for any help&

I need to first map a remote drive and then xcopy the files from that drive to the c:\ drive on the local drive using vbs & I'm new to VB  

xcopy mapped drive\localFolders "C:\msword\localFolders\*.*"  /E/D/I/R/Y
xcopy mapped drive\localFolders\wordmacros "c:\msword\wordmacros\*.*" /E/D/I/R/Y
xcopy mapped drive\localFolders\wordmacros "c:\Program files\Microsoft Office\Templates\Forms\*.*" /E/D/I/R/Y
xcopy mapped drive\localFolders\wordmacros\normal.dot "c:\Program files\Microsoft Office\Templates\" /y

Thanks again
fish_itAsked:
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.

William ElliottSr Tech GuruCommented:
don't use vbsscript forthis,.. do somethign like this

save as a bat
net use O: /delete
net use O: \\%%x\c$
 
echo %%x >> results.txt
 
xcopy O:\localFolders "C:\msword\localFolders\*.*"  /E/D/I/R/Y  >> results.txt
xcopy O:\localFolders\wordmacros "c:\msword\wordmacros\*.*" /E/D/I/R/Y >> results.txt
xcopy O:\localFolders\wordmacros "c:\Program files\Microsoft Office\Templates\Forms\*.*" /E/D/I/R/Y >> results.txt
xcopy O:\localFolders\wordmacros\normal.dot "c:\Program files\Microsoft Office\Templates\" /y >> results.txt
 
net use O: /delete

Open in new window

0
William ElliottSr Tech GuruCommented:
oops that was made for a 'for' loop

replce %%x with your computername and run it as a .bat file
0
William ElliottSr Tech GuruCommented:
but if you want vbs, this should work
Set objNetwork = CreateObject("WScript.Network")
Set objShell = CreateObject("WScript.Shell")
strUserName = objShell.ExpandEnvironmentStrings("%USERNAME%")
 
strDriveLetter2 = "x:"
strRemotePath2 = "\\SERVERNAME\sharename\"
 
CheckDrive = objNetwork.EnumNetworkDrives
AlreadyConnected = False
For intDrive = LBound(CheckDrive) To UBound(CheckDrive) - 1 Step 2
      If UCase(CheckDrive(intDrive)) = "x:" Then AlreadyConnected = True
Next
 
If AlreadyConnected = True Then
      objNetwork.RemoveNetworkDrive strDriveLetter2
      objNetwork.MapNetworkDrive strDriveLetter2, strRemotePath2
Else
      objNetwork.MapNetworkDrive strDriveLetter2, strRemotePath2
End If
 
objShell.run ("%comspec% /K title My Command Window |" _
			"xcopy x:\localFolders " & chr34 & "C:\msword\localFolders\*.*" & _
			chr34 & "  /E/D/I/R/Y", true)
 
objShell.run ("%comspec% /K title My Command Window |" _
			"xcopy x:\localFolders\wordmacros " & chr34 & _
			"c:\msword\wordmacros\*.*" & _
			chr34 & " /E/D/I/R/Y", true)
 
objShell.run ("%comspec% /K title My Command Window |" _
			"xcopy x:\localFolders\wordmacros " & chr34 & _
			"c:\Program files\Microsoft Office\Templates\Forms\*.*" & chr34 & _
			" /E/D/I/R/Y", true)
 
objShell.run ("%comspec% /K title My Command Window |" _
			"xcopy x:\localFolders\wordmacros\normal.dot " & chr34 & _
			"c:\Program files\Microsoft Office\Templates\" & chr34 & _
			" /y", 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
William ElliottSr Tech GuruCommented:
replace "title My Command Window "
with
title copying folders...
or whatever you want the title to be
0
fish_itAuthor Commented:
THANKS for both weellio... That was fast! First time using this site!
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
VB Script

From novice to tech pro — start learning today.