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?
 
William ElliottConnect With a Mentor Sr 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
 
William ElliottConnect With a Mentor Sr 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:
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
All Courses

From novice to tech pro — start learning today.