I stumbled across this posted by sealeopard.
I can't get it to work either.
Code:
$maxprofileage=20
$profilelist=$HKLM+'\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList'
$profiles=arrayenumkey($profilelist)
for each $usersid in $profiles
if $usersid<>'' and right($usersid,4)<>'-500'
$username=sidtoname($usersid)
$username=right($username,len($username)-instrrev($username,'\'))
;I added this*********
if $username='my.profile'
exit
endif
;*********************
if $username=''
$username='account unknown: '+$usersid
endif
$profiledir=expandenvironmentvars(readvalue($profilelist+'\'+$usersid,'ProfileImagePath'))
if $profiledir<>''
$userprofiles=dirlist($profiledir+'.*',1)
for each $userprofile in $userprofiles
$profiledate=getfiletime($userprofile+'\ntuser.dat')
$profiledate=left($profiledate,10)
if datemath($profiledate,@DATE)>$maxprofileage
$shellcommand='rd /s /q '+$userprofile
shell '%COMSPEC% /c '+$shellcommand
if $userprofile=$profiledir
$retcode=delkey($profilelist+'\'+$usersid)
endif
endif
next
endif
endif
next