PDA

View Full Version : Cannot delete SendTo or My Docs folder with DeleteFolder



davery83
11-24-2009, 03:27 AM
I've written a macro to remove roaming profiles from workstations (they're filling up the hard drive), its all working fine and I can delete all files and folders in each user profile except My Documents or the SendTo folder.
I get 'runtime error 70: permission denied'.
I've no idea how to set permissions with VBA or if it has something to do with admin rights, however I can delete this files manually with the same user I'm using to run the macro.
The folder has properties of read-only, however so does the other folders in the profile folder, and these can be deleted.
The code I've written skips the user if they are logged on (it checks ntuser.dat)to see if its open), so its not a problem with that either.
Can someone help please?

Bob Phillips
11-24-2009, 04:49 AM
I don't think you can, it is windows permission, and it is saying that you do not have sufficient privileges to delete files from that account. You probably need an account with administrator privileges.

davery83
11-24-2009, 04:51 AM
I don't think you can, it is windows permission, and it is saying that you do not have sufficient privileges to delete files from that account. You probably need an account with administrator privileges.
I have got privileges, I can delete them manually through explorer, and the other folders can be deleted, its just the 'SendTo' & 'My Documents' folders that I can't with the code.

Edit: Just checked with the system admin account, it fails at the same point.

davery83
11-24-2009, 05:49 AM
Managed it now, found that I needed to add true to the end of the code:
Original:
fso.DeleteFolder (Folder)
Amended:
fso.DeleteFolder (Folder), True