Wednesday, February 9, 2011

Script to Copy File from one Place to another

'Copy File from one Place to another
On Error Resume Next
dim objFSO
dim objFile

'specify filename and path for file to copy
strFile="c:\file.txt"
'specify target destination
strDest="c:\Neeraj\"

set objFSO=CreateObject("Scripting.FileSystemObject")
'set last parameter to TRUE if you want to overwrite
'an existing file with the same name
objFSO.CopyFile strFile,strDest,TRUE

if err.number=0 then
      wscript.Echo "Successfully copied " & strFile & " to " & strDest
else
      wscript.Echo "Failed to copy " & strFile & " to " & strDest
end if

set objFSO=Nothing

No comments: