rossnixon Posted September 17, 2008 Posted September 17, 2008 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.
Moderators SmOke_N Posted September 17, 2008 Moderators Posted September 17, 2008 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. 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.
anixon Posted September 18, 2008 Posted September 18, 2008 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
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