kor Posted May 6, 2009 Share Posted May 6, 2009 I am using this script and it seems to work great. #Include <Date.au3> #Include <File.au3> $FileList=_FileListToArray("C:\Documents And Settings", "*", 2) If @error Then Exit EndIf For $x = 1 to $FileList[0] $t = FileGetTime("C:\Documents And Settings\" & $FileList[$x], 0) $varTimeStamp = $t[0] & "/" & $t[1] & "/" & $t[2] & " " & $t[3] & ":" & $t[4] & ":" & $t[5] $varTimeDifference = _DateDiff ("D", $varTimeStamp, _NowCalc()) MsgBox (0, "Time Difference", "It's been " & $varTimeDifference & ' days since the profile "' & $FileList[$x] & '" was last accessed.') If $varTimeDifference >= 90 Then ;~ DirRemove ("C:\Documents And Settings\" & $FileList[$x], 1) EndIf Next However the message box reveals that the default user, all users, administrator profile, local service and network service are all on the chopping block. I do NOT want to delete those profiles. Administrator I'm not really concerned about but it would be nice to keep it in there. The big ones for me are being able to exclude default user, all users, local service and network service. Is there a way to exclude those profiles by manually defining them? I don't have a lot of experience with arrays so I'm not sure how to exclude things like that. Link to comment Share on other sites More sharing options...
lordicast Posted May 6, 2009 Share Posted May 6, 2009 (edited) Try this edit: added users #Include <Date.au3> #Include <File.au3> $FileList=_FileListToArray("C:\Documents And Settings", "*", 2) If @error Then Exit EndIf For $x = 1 to $FileList[0] $t = FileGetTime("C:\Documents And Settings\" & $FileList[$x], 0) $varTimeStamp = $t[0] & "/" & $t[1] & "/" & $t[2] & " " & $t[3] & ":" & $t[4] & ":" & $t[5] $varTimeDifference = _DateDiff ("D", $varTimeStamp, _NowCalc()) MsgBox (0, "Time Difference", "It's been " & $varTimeDifference & ' days since the profile "' & $FileList[$x] & '" was last accessed.') if $FileList[$x] = 'Administrator' Then Sleep(100) ElseIf $FileList[$x] = 'localservice' Then Sleep(100) ElseIf $FileList[$x] = 'networkservice' Then Sleep(100) ElseIf $FileList[$x] = 'All Users' Then Sleep(100) ElseIf $FileList[$x] = 'Default User' Then Sleep(100) Else If $varTimeDifference >= 90 Then DirRemove ("C:\Documents And Settings\" & $FileList[$x], 1) EndIf EndIf Next Edited May 6, 2009 by lordicast [Cheeky]Comment[/Cheeky] Link to comment Share on other sites More sharing options...
kor Posted May 6, 2009 Author Share Posted May 6, 2009 That worked great. thanks! Is there a way to distinguish between a roaming profile and a local profile? If I look at the profiles advanced options in the windows advanced properties it will tell me... but right clicking on a particular profile folder I see nothing in there that says one way or the other. How does windows tell the difference? Link to comment Share on other sites More sharing options...
skysel Posted July 16, 2009 Share Posted July 16, 2009 While this script serves it's purpouse, the dates for profiles when they were last accessed are mostly wrong. However I don't have any idea at the moment, how to modify it to check for real last access date? Example.. for my profile current script says it's been 45 days since it has been last accessed, but I'm using it daily Any suggestions welcome... Link to comment Share on other sites More sharing options...
lordicast Posted July 16, 2009 Share Posted July 16, 2009 works just fine for me, 0 days. I could not replicate your issue? what version of windows you have? [Cheeky]Comment[/Cheeky] Link to comment Share on other sites More sharing options...
skysel Posted July 17, 2009 Share Posted July 17, 2009 (edited) That might be the issue.. Windows 7 edit: Just tried it on WinXP, it reports 0 days for All Users and Default User, but for user currently logged on it reports 28 days. So, problem still exists.. Edited July 17, 2009 by skysel Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now