pinkpanther56
Technical User
The script below deletes windows local profiles at boot time we use this to clear up any dead mandatory profiles. There is a section at the bottom that excludes certain profiles e.g administrator.
Can anyone make a suggestion on how the script could be altered to read the excluded profiles from a text file or .csv file so I could have a list of staff profiles that I don't want deleting, or even better if it could query Active Directory for group membership I know that last bit might be a tall order so I'm happy to start with a text file for now and work from there
Any VB ninjas care to offer advice?
Thanks.
Can anyone make a suggestion on how the script could be altered to read the excluded profiles from a text file or .csv file so I could have a list of staff profiles that I don't want deleting, or even better if it could query Active Directory for group membership I know that last bit might be a tall order so I'm happy to start with a text file for now and work from there
Any VB ninjas care to offer advice?
Thanks.
Code:
' Deletes local profiles from hard disk at MACHINE STARTUP this prevents logon problems when the profile is copied from the 'server
On Error Resume Next
Sub DeleteFolders(strRoot, strExclude)
On Error Resume Next
Dim fso, f, fc, folder, arrExcl, folderName, folderPath, i, isExcl
arrExcl = Split(strExclude, ",")
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder(strRoot)
For Each folder in f.SubFolders
folderName = LCase(folder.name)
folderPath = LCase(folder.path)
isExcl = False
i = 0
Do While i < UBound(arrExcl) + 1
If Lcase(arrExcl(i)) = folderName Then
isExcl = True
End If
i = i + 1
Loop
If isExcl = False Then
fso.DeleteFolder folderPath, True
End If
Next
End Sub
Call DeleteFolders("c:\documents and settings\", "administrator,All Users,Default User,")
'Usage: DeleteFolders("full path to folder, ending in \", "list of folders to be excluded, separated by a comma, no slashes")