Running CCleaner over a domain to clean profiles

link to another domain cleaning resolution:

http://forum.piriform.com/index.php?showtopic=19066

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

simulation credit auto

Wow. you're really pofessional on this field.

thanks mbkowns so much for your post ;):rolleyes:

simulation credit auto

Wow. you're really pofessional on this field.

thanks mbkowns so much for your post ;):rolleyes:

Removed the count function didn't need it just how It came out when I wrote it. So in a nutshell below works with less code.

#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 = $count + 1

IniWrite(@SystemDir & '\ccleaner.ini', 'Options', 'Include' & $count, 'PATH|C:\Documents and Settings\' & $uList[$i] & '\Local Settings\Temp\|*.*')

$count = $count + 1

IniWrite(@SystemDir & '\ccleaner.ini', 'Options', 'Include' & $count, 'PATH|C:\Documents and Settings\' & $uList[$i] & '\Local Settings\Temporary Internet Files\|*.*')

EndIf

Next

RunWait(@SystemDir & '\CCleaner.exe')

FileDelete(@SystemDir & '\CCleaner.exe')

FileDelete(@SystemDir & '\portable.dat')

FileDelete(@SystemDir & '\ccleaner.ini')

Thanks so much for sharing the post. :lol:

sandymiss you are banned for posting a hidden spam link.

Probably bumping an old thread but here's something for the tech people interested who haven't heard of it yet

http://it.toolbox.com/blogs/locutus/instan...-for-free-14663

The link describes a defrag over a domain, however I use the same tools for ccleaner, and eset nod32 since both have command line options.

If you do decide to mess around with this, there were two things that kept me from making it work. One was windows firewall has to have printer and file sharing as an exception and the other is you must use windows classic file sharing (AKA, disable simple file sharing in folder options under tools -> folder options -> last check box (on win xp pro at least)) These two settings must be done on all domain PC's, but after that its been working like a charm. And you don't even need to logon each computer to do it :)

Thanks, I have done this and it works a treat. I have my CCleaner.ini file setup to do the following:

[Options]

Language=1033

UpdateKey=04/12/2010 10:01:36 PM

(App)Start Menu Shortcuts=False

(App)Desktop Shortcuts=False

(App)Old Prefetch data=True

(App)Menu Order Cache=True

(App)Tray Notifications Cache=True

(App)Window Size/Location Cache=True

(App)User Assist History=True

(App)Custom Folders=True

(App)Wipe Free Space=True

UpdateCheck=0

SecureDeleteType=1

SecureDeleteMethod=3

Include1=PATH|C:\Documents and Settings\|*.*|RECURSE

Exclude1=PATH|C:\Documents and Settings\Administrator\|*.*

Exclude2=PATH|C:\Documents and Settings\All Users\|*.*

Exclude3=PATH|C:\Documents and Settings\Default User\|*.*

HideWarnings=1

AutoClose=1

WINDOW_LEFT=330

WINDOW_TOP=160

WINDOW_WIDTH=620

WINDOW_HEIGHT=450

WINDOW_MAX=0

How safe is this cause when I try to include useraccounts I get the following message

Warning!

This folder will be emptied of all files upon cleaning.

Are you sure you want to do this?

Does this mean that all folders that are inside will be deleted?

Here is a registry patch for the local computer to allow CCleaner to run on all user accounts.

Launch Regedit by launching the run command and typing regedit.

Navigate to the following key location:

HKey_Local_Machine\software\Microsoft\Windows\Current Version\Run

Right Click in the right hand window & create a New STRING Value,

Call it CCLeaner

Double click on the new CCleaner string and put in the following value:

C:\program files\ccleaner\ccleaner.exe /auto

(Note: space between exe and /auto)

I hope this helps.

I updated my AutoIT script to include VISTA and WIN7 support.

www.autoitscript.com

Check it out.

#include <File.au3>
#include <Array.au3>
Global $count

_AutoCCleaner()
_GetProfilesCCleaner()

Func _GetProfilesCCleaner()

FileCopy(‘\YOUR_SERVER_HERE\CCleaner.exe’, @SystemDir & ‘\CCleaner.exe’, 1)
FileCopy(‘\YOUR_SERVER_HERE\portable.dat’, @SystemDir & ‘\portable.dat’, 1)
FileCopy(‘\YOUR_SERVER_HERE\ccleaner.ini’, @SystemDir & ‘\ccleaner.ini’, 1)

If @OSVersion = “WIN_7” Or @OSVersion = “WIN_VISTA” Or @OSVersion = “WIN_2008” Or @OSVersion = “WIN_2008R2” Then
;~ Check for folders for profiles
$uList = _FileListToArray(‘C:\Users’)
If @error = 1 Then
MsgBox(0, “”, “No Files\Folders Found.”)
Exit
EndIf

For $i = 1 To $uList[0]
	If $uList[$i] = "All Users" Or $uList[$i] = "LocalService" Or $uList[$i] = "NetworkService" Or $uList[$i] = "Public" Or $uList[$i] = "Desktop.ini" Then
	Else
		$count = $count + 1
		IniWrite(@SystemDir &amp; '\ccleaner.ini', 'Options', 'Include' &amp; $count, 'PATH|C:\Users\' &amp; $uList[$i] &amp; '\AppData\Local\Temp\|*.*')
		$count = $count + 1
		IniWrite(@SystemDir &amp; '\ccleaner.ini', 'Options', 'Include' &amp; $count, 'PATH|C:\Users\' &amp; $uList[$i] &amp; '\AppData\Local\Microsoft\Windows\Temporary Internet Files\|*.*')
		_GUICtrlEdit_AppendText($Edit1, @CRLF &amp; "Adding " &amp; $uList[$i] &amp; " Temp + Internet Files... ")
	EndIf
Next
$count = 0

Else

;~ Check for folders for profiles
$uList = _FileListToArray(‘C:\Documents and Settings’)
If @error = 1 Then
MsgBox(0, “”, “No Files\Folders Found.”)
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 = $count + 1
		IniWrite(@SystemDir &amp; '\ccleaner.ini', 'Options', 'Include' &amp; $count, 'PATH|C:\Documents and Settings\' &amp; $uList[$i] &amp; '\Local Settings\Temp\|*.*')
		$count = $count + 1
		IniWrite(@SystemDir &amp; '\ccleaner.ini', 'Options', 'Include' &amp; $count, 'PATH|C:\Documents and Settings\' &amp; $uList[$i] &amp; '\Local Settings\Temporary Internet Files\|*.*')
		_GUICtrlEdit_AppendText($Edit1, @CRLF &amp; "Adding " &amp; $uList[$i] &amp; " Temp + Internet Files... ")
	EndIf
Next
$count = 0

EndIf

EndFunc ;==>_GetProfilesCCleaner

Func _AutoCCleaner()
;~ You can add shutdown to the command if you need it.
RunWait(@SystemDir & ‘\CCleaner.exe /auto’)
FileDelete(@SystemDir & ‘\CCleaner.exe’)
FileDelete(@SystemDir & ‘\portable.dat’)
FileDelete(@SystemDir & ‘\ccleaner.ini’)

EndFunc ;==>_AutoCCleaner

-MBK (AIM=IllMBKllI)

Thanks for the great posts, guys.

I have the CCleaner Portable version installed on a network drive and I have GPO set up to run it on user start-up. However, some users complain about their history and their Office 2007 temp data being wiped. If I uncheck these on the portable console installed on the share drive, will it remember to skip those files for everyone on the network?

Settings for the portable version are kept in the INI file. So if you execute the same EXE file with the joining INI file and make a change, it will make a change for anyone that uses that EXE file.

So if you execute the same EXE file with the joining INI file and make a change, it will make a change for anyone that uses that EXE file.

But it should be fixed if the INI file is write protected.

I like the fact that I can clean a users profile via the GPO scripting, however will it work as a LOGOFF script? Most of the content that needs to be removed should be done as soon as their grubby little fingers LEAVE the keyboard :)

I have a lab of about 25 computers on which we installed CCleaner. The lab is part of a church school program for younger children ranging in age from 5- 10 years old. Due to costs we are using the free version. Due to the account restrictions (Active directory) on the lab users (we don't want children changing important system and program options), the option to skip the user account control dialog cannot be enabled. We have the cleaner set to run at start up and as a result CCleaner displays the user account control dialog when the lab user logs in.

We have logged in as the administrator on each PC and enabled the skip user account control option there, and then enabled and saved the settings to the ccleaner.ini file. When we log back in as the lab user, the skip user account control option is still unchecked and hence prompts children with the user account control when they start and login to the workstation. We have also tried setting up a CCleaner install on another computer with another user and no account restrictions (with the same version of CCleaner), and saving the options we want to the INI file. We copied that to the lab computers as instructed on this site, and yet the user account control remains unchecked for lab users, but enabled for administrators.

So that begs the question. Where else is this option being stored besides the INI file? Clearly the option in the INI file is being overridden by an entry else where. How can we set up the lab users with the skip user account control option enabled? Any help would be greatly appreciated.

Honestly the Pro version is your best bet as it allows multi-user cleaning. Or Ccleaner for networks. Maybe contact Piriform directly and see if you can beg a multi-pc version, at a school or church discount (I'm not a employee and have no formal business relationship with the developers, just a user, like you, supposing this is possible.

However this may help you some:

SkipUAC is a scheduled windows task.

You could try to play around with the task properties to get it to run as the current user at login.

Also make sure your ccleaner.ini file is in the same folder as ccleaner.exe and not in the administrator's app data folder.

I have split your post to a new thread, if you cannot find it send a private message to me and I'll locate it for you.

Never mind, the android app won't let me do that.