Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

How to copy and over-write read only files

Avatar of HSA10036
HSA10036 asked on
VB Script
4 Comments1 Solution787 ViewsLast Modified:
I want to copy read only files located on my computer to the server. Files from my computer will replace files with the same name located on the server called Fin-ibmserver. The files are read only on the server as well as on my computer.

I researched available solutions and came up with this:

Set objFSO = CreateObject ("Scripting.FileSystemObject")
strFromFolder = "C:\Documents and Settings\hsa\Desktop\Audit\QB-RemovedPW"
strToFolder = "\\Fin-ibmserver\QBField"

'Change attributes on ToFolder
For Each strFile In objFSO.GetFolder("\\Fin-ibmserver\QBField").Files
  Set objFile = objFSO.GetFile(strFile)
  If objFile.Attributes = objFile.Attributes AND 1 Then
      objFile.Attributes = objFile.Attributes XOR 1
  End if
Next

'Change attributes on FromFolder and then Copy
For Each strFile In objFSO.GetFolder("C:\Documents and Settings\hsa\Desktop\Audit\QB-RemovedPW").Files
  Set objFile = objFSO.GetFile(strFile)
  If objFile.Attributes = objFile.Attributes AND 1 Then
      objFile.Attributes = objFile.Attributes XOR 1
  End if
objFile.Copy strToFolder, True      
Next

The error message I get is that permission is denied when executing objFile.Copy
I can drag and drop the file manually without an error message.
Your help is greatly appreciated. Please keep it simple since I am not a programmer.