Access denied

G

Guest

I'm using WSH with a VBScript file to copy folders and files from a network
to my local drive. The first time it runs fine, creates the new folders and
copies the files. But it creates them (all the copied files) as "readonly"
and I cannot modify this attribute. I created the original files on the
network as well, so you would think I have full rights to these files. I
have tried manually changing the readonly attribute with Windows Explorer,
but it does not keep the new attribute. I have modified the security
settings to give myself full access to the new folders, but I still cannot
make the change.

Any ideas out there?

A note to Michael, frequent contributor: a folder may not have a "readonly"
attribute, but the readonly attribute can be set for a folder object using
the filesystemobject, meaning that all of its files' (and subfolders and
their files??) attributes can be set. It really is misleading!
 
S

Saucy

Marty said:
I'm using WSH with a VBScript file to copy folders and files from a
network
to my local drive. The first time it runs fine, creates the new folders
and
copies the files. But it creates them (all the copied files) as
"readonly"
and I cannot modify this attribute. I created the original files on the
network as well, so you would think I have full rights to these files. I
have tried manually changing the readonly attribute with Windows Explorer,
but it does not keep the new attribute. I have modified the security
settings to give myself full access to the new folders, but I still cannot
make the change.

Any ideas out there?

A note to Michael, frequent contributor: a folder may not have a
"readonly"
attribute, but the readonly attribute can be set for a folder object using
the filesystemobject, meaning that all of its files' (and subfolders and
their files??) attributes can be set. It really is misleading!


You *probably* should be asking this is a newsgroup more oriented to
programming and scripting, e.g.

microsoft.public.scripting.wsh

Saucy
 
G

Guest

The script is not the issue. The issue is that I cannot remove the readonly
attribute from these files, regardless of how they were created.
 
J

Jon

Marty said:
The script is not the issue. The issue is that I cannot remove the
readonly
attribute from these files, regardless of how they were created.



You could try removing the 'Read Only' attribute programmatically prior to
your copy, assuming that's the problem eg something like.......



Set fso= CreateObject("Scripting.FileSystemObject")


'Change the path to where you are copying to
SetAttributes "C:\Users\Marty\Desktop\targetfolder\"


'---------------------------
Sub SetAttributes(fn_FolderPath)

Set a = fso.GetFolder(fn_FolderPath)

For each objFileItem in a.Files
objFileItem.attributes = (objFileItem.attributes) and 254
Next

For each objFolderItem in a.SubFolders
SetAttributes(objFolderItem.Path)
Next


Set a = nothing

End Sub
'--------------------------------

'Then do your copying......
 
G

Guest

Jon -

That was it! The problem was that one (or perhaps a few) of the many files
I was trying to copy were readonly in their original, so when I tried to copy
all of them the second time I got the access error. I did pretty much what
you suggested and it worked.

Thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top