# Delete Profiles VBS Script



## Guest (Apr 4, 2010)

I have acquired a script from the internet which deletes all the locally cached profiles on a computer if they are not on the specified list of exceptions.

By default, I think it does something like this:

Gets all the folders in the 'Users' directory > Goes through the list of exceptions > Deletes all the folders which aren't on the list of exceptions > If a folder can't be deleted, it leaves it behind and goes onto the next one. (This means it doesn't hang).

This is ok, but a lot of the time, profiles with incorrect owners are present. In this case, the script won't be able to delete the profile, will move onto the next one, leaving it behind. I need all the folders which are non-exempt to be deleted.

I need it to do the following:

Get all the folders in the 'Users' directory > Go through the list of exceptions > Change the owner of all folders which are non-exempt > Delete all folders which are non-exempt (which it should be able to do at this point) > In case of some unknown error, go onto the next one (for the sake of it not hanging).

I have had a go at this myself, but I haven't quite got it. Note: I may need to set the permissions as well, but if I can get it to set the owner, I can simply add the permissions bit as a switch on the subinacl command.

I have attached the script. Please let me know if you need any more information and thanks for any help with this.

Matthew.


----------

