serverguy78
MIS
Hello, I'm trying to write a script that will copy a whole directory of folders to another location and overwrite the files in the destination folder. The problem I have now is that this script will only copy one file or one folder. I need to be able to copy a directory full of backups
Can someone help me. Here is my script
Option Explicit
Dim objNetwork,strUser,strPassword,strPath, strDriveLetter
Dim ObjFso
Dim WshNetwork,oDrives,i
Dim StrSourceFolder
Dim StrDestinationFolder
Set WshNetwork = WScript.CreateObject("WScript.Network")
Set oDrives = WshNetwork.EnumNetworkDrives
Set objNetwork = WScript.CreateObject("WScript.Network")
For i = oDrives.Count-2 To 0 Step -2
If oDrives.Item(i) = "S:" Then
WshNetwork.RemoveNetworkDrive oDrives.Item(i),True,True
End If
Next
strDriveLetter = "S:"
strPath = "\\******\BackUps"
StrSourceFolder = "\\*******\BackUps\trk\backup"
StrDestinationFolder = "H:\vbscripts\backup"
strUser = "******\******"
strPassword = "******"
objNetwork.MapNetworkDrive strDriveLetter,strPath
'Creating the file system object
Set ObjFso = CreateObject("Scripting.FileSystemObject")
'Copying the file
ObjFso.CopyFile StrSourceFolder, StrDestinationFolder'true
wscript.echo "Copy Complete"
WScript.Quit
Can someone help me. Here is my script
Option Explicit
Dim objNetwork,strUser,strPassword,strPath, strDriveLetter
Dim ObjFso
Dim WshNetwork,oDrives,i
Dim StrSourceFolder
Dim StrDestinationFolder
Set WshNetwork = WScript.CreateObject("WScript.Network")
Set oDrives = WshNetwork.EnumNetworkDrives
Set objNetwork = WScript.CreateObject("WScript.Network")
For i = oDrives.Count-2 To 0 Step -2
If oDrives.Item(i) = "S:" Then
WshNetwork.RemoveNetworkDrive oDrives.Item(i),True,True
End If
Next
strDriveLetter = "S:"
strPath = "\\******\BackUps"
StrSourceFolder = "\\*******\BackUps\trk\backup"
StrDestinationFolder = "H:\vbscripts\backup"
strUser = "******\******"
strPassword = "******"
objNetwork.MapNetworkDrive strDriveLetter,strPath
'Creating the file system object
Set ObjFso = CreateObject("Scripting.FileSystemObject")
'Copying the file
ObjFso.CopyFile StrSourceFolder, StrDestinationFolder'true
wscript.echo "Copy Complete"
WScript.Quit