I'm trying to copy a file from one location to another and I'm getting object doesn't support this property or method: 'objFSO.FileCopy' error. What am I doing wrong with the code below and how can I correct it?
Code:
' objects needed to aquire username
Set objNetwork = CreateObject("WScript.Network")
Set objUser = CreateObject("ADSystemInfo")
Set UserName = GetObject("LDAP://" & objUser.UserName)
strDirDes = "C:\Documents and Settings\" & objNetwork.UserName & "\Application Data\Microsoft\Templates"
strDir = "\\chcb6\install$\templates"
'array that contains the file names
arrFileName = array("\CHCB Letterhead.doc", "\CHCB Memo Template.doc", "\CHCB Policy & Procedure Template.doc", _
"\CHCB Admin FAX Template.doc", "\CHCB Clinical FAX Template.doc")
Set objFSO = CreateObject("Scripting.FileSystemObject")
for each name in arrFileName
If objFSO.FileExists(StrDirDes & name) Then
Wscript.Echo "File does exist."
Else
'Wscript.Echo strDir & name
objFSO.FileCopy strDir & name , strDirDes & name
End If
next