stayingdusty
asked on
Deleting Old Profiles
I have peiced together some script from various resources to try to accomplish this goal:
I want a script that will delete all local user profiles over 6 months old, except ones with the names:
"Administrator"
"All Users"
"nvconfig"
"OtherExamples"
Here is the Code I currently have, please help me figure out what I am doing wrong.
'========================= ========== ========== ========== ==========
Const LocalDocumentsFolder = "C:\Documents and Settings\"
set objFSO = createobject("Scripting.Fi leSystemOb ject")
set objFolder = objFSO.GetFolder(localdocu mentsfolde r)
set profolder = objFolder.SubFolders
on error resume next
for each fldr in profolder
if not isexception(fldr.name) AND DateDiff("D", profolder.DateLastModified , Now) < 180 Then
'objFSO.DeleteFolder fldr.path, True
wscript.echo "Deleted Folder: " & profolder
end if
next
Function isException(byval foldername)
select case foldername
case "All Users"
isException = True
case "Default User"
isException = True
case "nvconfig"
isException = True
case "admin"
isException = True
case "Administrator"
isException = True
case Else
isException = False
End Select
End Function
'========================= ========== ========== ========== ===
I want a script that will delete all local user profiles over 6 months old, except ones with the names:
"Administrator"
"All Users"
"nvconfig"
"OtherExamples"
Here is the Code I currently have, please help me figure out what I am doing wrong.
'=========================
Const LocalDocumentsFolder = "C:\Documents and Settings\"
set objFSO = createobject("Scripting.Fi
set objFolder = objFSO.GetFolder(localdocu
set profolder = objFolder.SubFolders
on error resume next
for each fldr in profolder
if not isexception(fldr.name) AND DateDiff("D", profolder.DateLastModified
'objFSO.DeleteFolder fldr.path, True
wscript.echo "Deleted Folder: " & profolder
end if
next
Function isException(byval foldername)
select case foldername
case "All Users"
isException = True
case "Default User"
isException = True
case "nvconfig"
isException = True
case "admin"
isException = True
case "Administrator"
isException = True
case Else
isException = False
End Select
End Function
'=========================
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER