Jump to content

yzharovsky

Member
  • Posts

    2
  • Joined

  • Last visited

  • Donations

    0.00 USD 
  • Country

    United States

About yzharovsky

yzharovsky's Achievements

0

Reputation

  1. Greetings Yzöwl Thank you for your reply I have ran your script and wanted to let you know that it too errors out in Documents and Settings on folders starting with the letter "mz". I am running this script on my local machine and I am logged in as Administrator, also keep in mind that the folder starting with mz was created by me and has nothing inside the folder (the folder is empty) You can easily try your script on your own machine, just make sure you are pointing it to Documents and Settings because the script does work in any other folder. Thank you again for your reply Cheers Yevgeny
  2. Greetings All I am running a VB script to delete folders which are not "Administrator" "All Users" or "Default Users" The Script works fine in every folder except for "Documents and Settings" In "Test" directories it will delete everything except for the folders listed above; as it should. However once I run the scrip against directory "Documents and Settings" the script will generate an error if there are folders which start with the letter "M" or any letter there after. (Please note that you can create a folder starting with the letter M in Documents and Settings and you will get the error, it seems that the error has nothing to do with profile folders but just folder names.) Example " folder with the letter "A" such as "Aaaa" will be deleted however folder "Mmmmm" or "mmmb" or "mom" will not be delete and the script will generate an error of "Access Denied" ( There is no error or problem against locked folders such as Administrator ) I also did some tests and figured out that it’s not even the letter "M" that is the issue, the issue starts with folder name "Loo" So folder name "L" will be deleted while folder "Lz" will give me an error. Here is the script You can look at it and even try it yourself. I know Documents and Settings folder is very special, what I want to know is how and what change is made to Documents and Settings vs other folders. I did get my script to work, by inserting a "Resume on Error" command and it does then delete all the folders including the ones starting with M. But I still am very curious. Cheers Yevgeny This one will generate the error in Documents and Settings I commented out the part that fixes the error. Set fso=CreateObject("Scripting.FileSystemObject") CleanPath="C:\Documents and Settings\" For Each file In fso.GetFolder(CleanPath).Files file.attributes = file.attributes And Not 1 file.delete Next Set fso = CreateObject("Scripting.FileSystemObject") Set oFolder = fso.GetFolder("C:\Documents and Settings\") arrFolders = Array() For Each oFolder In oFolder.SubFolders ' Note : Only use *lowercase* letters in the folder names below: If Not LCase(oFolder.Name) = "administrator" _ And Not LCase(oFolder.Name) = "all users" _ And Not LCase(oFolder.Name) = "default user" Then intCount = UBound(arrFolders) + 1 ReDim Preserve arrFolders(intCount) arrFolders(intCount) = oFolder.Path End If Next For n = 0 To UBound(arrFolders) ' On Error Resume Next fso.DeleteFolder arrFolders(n), True Next
×
×
  • Create New...