A. You can check file-copy operations by using the Err value, and after the copy, you can perform a FileExists operation to confirm that the new file exists, as you see in the code below. You can save this script, passing a folder and filename as the first parameter, and the folder to copy to as the second the folder:
On Error Resume Next
Dim objFSO, sourceFile, targetFolder
set sourceFile = objFSO.GetFile(WScript.Arguments(0))
set targetFolder = objFSO.GetFolder(WScript.Arguments(1))
objFSO.CopyFile sourceFile, targetFolder
If Err.Number 0 Then
Wscript.Echo "File copy problem " & err.number, err.description
If objFSO.FileExists(targetFolder.Path & "\" & sourceFile.Name) Then
Wscript.Echo "File Copied"
You can add additional logic and perform other actions in the scripts, if necessary. Here is the script running normally:
D:\Temp>cscript copyfilecheck.vbs d:\temp\blob.file g:\data\
Microsoft (R) Windows Script Host Version 5.7
Copyright (C) Microsoft Corporation. All rights reserved.
File copy problem 70 Permission denied