I want to execute a file copy, using vbscript and have builtin validation of the file copy.

How can this be done ?
I want the script to check whether it has copied a certain directory and then delete it.
itbabeAsked:
Who is Participating?
 
Tony MassaConnect With a Mentor Commented:
Generally, the file will copy fine, or create an Err Code.  For instance, if the network connection goes down in the middle, the script will throw an error, but if it's REALLY important, you can MD5 checksum both files before deleting it:

http://www.robvanderwoude.com/vbstech_files_md5.html

Copy A File:
Const OverwriteExisting = TRUE

Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.CopyFile "C:\FSO\ScriptLog.txt" , "D:\Archive\", OverwriteExisting

Move A File (Copy/Delete)


Const OverwriteExisting = TRUE

Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.CopyFile "C:\FSO\ScriptLog.txt" , "D:\Archive\", OverwriteExisting

If err.Number = 0 Then
  objFSO.DeleteFile("C:\FSO\ScriptLog.txt")
Else
  WScript.Echo "There was an error: " & err.Description
End If
0
 
Richard QuadlingSenior Software DeveloperCommented:
You could also use the DOS COPY command with the /V parameter.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.