Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copy a folder and associated ACLs

Status
Not open for further replies.

ksum

Technical User
Dec 7, 2005
11
US
Hello all,

Does anyone know of a way to use VB6 to copy a folder, all of the contents, including subfolders and their contents, and keep the ACLS the same as they are on the source folder? The source and destinations are on the same drive.

Aparently the FSO CopyFolder does not copy the security permissions.

Regards,
Karl Sumwalt
 
Security is there to STOP people copying etc if you dont want them to. Being able to get around this would negate the concept of "permissions
 
I am not trying to get around it, but preserve it.

I am trying to copy a folder and all of it's contents, under a log-in with administrator privelages. A login with full rights to the folder, so I am not trying to get around permissions, only copy a folder via VB and the permissions on the copy as they are set on the original.

XCopy has a switch to do just this. For now I am shelling to an xcopy command. (Worked this out after posting themessage.) I would like to do this without the use of a shell.
 
Ypu might like to look at the GetSecurityDescriptor and SetSecurityDescriptor methods of the Win32_LogicalFileSecuritySetting WMI class.

There are a set of API calls to achive similar in a more light-weight fashion, but they are quite a pain to use.
 
I have often wondered how they set a file like a database or a temp file from a sharing site so it cant be copied while the browser is running (file used by another application error).

If pull out the power plug of the computer with the application running, and restart it, this restriction is removed and you can copy it or use it with another application later so the trouble sharing sites go to is of little use in preventing piracy.
However, if you close the browser or database application before switching off the computer, the file is uncopyable until closed or if it is a tmp file, it is erased.
I don't think therefore that this can be an attribute of the file itself as the file surely cant know the difference?

Anybody know what is the mechanism that achieves this behavior?
 
strongm,

This did point me in a good direction. In the end, I put a copy of robocopy in the same folder as the executable and created a command line with the Shell function. It was just easier than stepping thru each folder and file, reading everything's descriptors, and then setting the copies to match.

I appreciate the information, as it pointed me to the realization that, for my needs, the end result is better handled with other means.

As a note, I originally used xcopy, since it seems to be delivered in the Windows OS, but found it did not work on all machines or logins (we didn't research which) so I used my prefered robocopy. I just had to make sure it was accessible to the program. The best way to do this was include it in the distribution and run both from the current directory.

Karl
 
>I would like to do this without the use of a shell.
I'd have suggested Robocopy if you hadn't said the above ...

>Xcopy ... did not work on all machines or
And is deprecated in Vista in favour of Robocopy
 
I was hoping there was an easier way to avoid the Shell function, if for no other reason, to keep everything neetly inside a single executable.

Anyway, thank you for the assistance. It is much appreciated.

Karl
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top