Jump to content

Script to Delete files from all profiles


mbkowns

Recommended Posts

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

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.