Sign in to follow this  
Followers 0
rossnixon

Delete all from %temp% older than xx hours

3 posts in this topic

Has anyone written a script that will delete all files and folders from their Windows %temp% folder that are older than xx hours?

I want to put this into a startup batch file to automate the process. CCleaner can do it, but I'm not sure if this can be scripted to run invisibly.

Share this post


Link to post
Share on other sites



Has anyone written a script that will delete all files and folders from their Windows %temp% folder that are older than xx hours?

I want to put this into a startup batch file to automate the process. CCleaner can do it, but I'm not sure if this can be scripted to run invisibly.

Read the directory into a list array with _FileListToArray(), then use FileGetTime() to get the information you need/want, then use FileDelete(). Should be fairly straight forward.

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

Has anyone written a script that will delete all files and folders from their Windows %temp% folder that are older than xx hours?

I want to put this into a startup batch file to automate the process. CCleaner can do it, but I'm not sure if this can be scripted to run invisibly.

I use this routine to check that system files are available in a startup situation which you can possibly adapted to your requirements:

I have only included three of the Const to demonstrate how I accommodate the files I am looking for.

CODE

Const $SkypeApp = @ProgramFilesDir & "\Skype\Phone\Skype.exe" ;Skype Client

Const $SkypeAppPM = @ProgramFilesDir & "\Skype\Plugin Manager\SkypePM.exe" ;Skype Extra's required by Skype4COM

Const $ScriptDirS = @ScriptDir & "\sSentry.ini" ;System Sentry INI

;//Check System Health

Func _sSentrySystemHealth()

;//Select Program and Associated file/s that

Global $File[13] = [$SkypeApp, $SkypeAppPM, $sSBanner, $sSIconI, $sSIconS, $sSIconU, $AlertSound, _

$ScriptDirS, $ScriptDirM, $sSInstall, $sSUninstall, $sSLicence, $sSLicFile]

For $i = 0 To UBound($File) - 1

$FileName = $File[$i]

If Not FileExists($FileName) Then

_MessageAndLog(0, 0, $sSLogDirM, $s_LogFileID, 1, 0, $FileName & " ** FILE MISSING OR CORRUPT ** ")

MsgBox(262160, $Title, " ** PROGRAM STOPPED CONTACT ADMINISTRATOR **")

Exit

EndIf

Next

;//Read sSentry.ini file

_RsSentryINI()

;//Read sSEmail.ini file

_RsSEMailINI()

;//Write the Start Message to the Log

If $sSentryStartUpFlag = 1 Then

_MessageAndLog(0, 0, $sSLogDirM, $s_LogFileID, $WriteLog, 0, "sSentry STARTUP - " & StringLower(@ComputerName))

_MessageAndLog($MessageDisplay, $MessageDelay, $sSLogDirM, $s_LogFileID, 0, 1, "sSentry STARTUP ")

$sSentryStartUpFlag = 0

EndIf

EndFunc

Share this post


Link to post
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
Sign in to follow this  
Followers 0