Jump to content


Script to Delete files from all profiles


  • You cannot reply to this topic
No replies to this topic

#1 OFFLINE   mbkowns

    Newbie

  • Members
  • Pip
  • 5 posts

Posted 04 June 2009 - 03:05 PM

I wrote an AutoIT script that will parse the profile directory and add lines in the CCleaner.ini file to delete "temp" and "temporary internet files"

This is then just a job that is run in Altiris regardless if users are logged in or out. I also have it deleting CCleaner off the machine after so I don't have to leave it there.

#include <File.au3>
#include <Array.au3>
Global $count
FileCopy('\\YOURSHARE\CCleaner\CCleaner.exe', @SystemDir & '\CCleaner.exe', 1)
FileCopy('\\YOURSHARE\CCleaner\portable.dat', @SystemDir & '\portable.dat', 1)
FileCopy('\\YOURSHARE\CCleaner\ccleaner.ini', @SystemDir & '\ccleaner.ini', 1)

;~ Check for docs and settings for profiles
$uList = _FileListToArray('C:\Documents and Settings')
If @error = 1 Then
Exit
EndIf

For $i = 1 To $uList[0]

If $uList[$i] = "All Users" Or $uList[$i] = "Default User" Or $uList[$i] = "LocalService" Or $uList[$i] = "NetworkService" Then
Else
_Count()
IniWrite(@SystemDir & '\ccleaner.ini', 'Options', 'Include' & $count, 'PATH|C:\Documents and Settings\' & $uList[$i] & '\Local Settings\Temp\|*.*')
_Count()
IniWrite(@SystemDir & '\ccleaner.ini', 'Options', 'Include' & $count, 'PATH|C:\Documents and Settings\' & $uList[$i] & '\Local Settings\Temporary Internet Files\|*.*')
EndIf

Next

$count = 0

RunWait(@SystemDir & '\CCleaner.exe')
FileDelete(@SystemDir & '\CCleaner.exe')
FileDelete(@SystemDir & '\portable.dat')
FileDelete(@SystemDir & '\ccleaner.ini')

Func _Count()
$count = $count + 1
EndFunc ;==>_Count