Caaio Posted July 9, 2007 Posted July 9, 2007 Dear guys,i`m trying to make a script that erase Temp files, but i didn`t have success in all tests that i made:I`m trying with#include <Process.au3>;apaga TMP_RunDOS (@TempDir & "del *.* /s /q")The script is executed without error message, but the temp files still appearing.What`s wrong in my script?!Thans who can help me.Regards.
Caaio Posted July 9, 2007 Author Posted July 9, 2007 Sorry guys, but i`m new in AutoIt scripts. And i will thank you if you can give me some tips to do this simple script! thanks again. Regards.
ChrisL Posted July 9, 2007 Posted July 9, 2007 _RunDOS ("Del " & @tempdir & "\*.* /s /q" ) Maybe [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire
mrbond007 Posted July 9, 2007 Posted July 9, 2007 instead of using dos why not Autoit_DeleteFiles(@TempDir, "*.*", 1) Func _DeleteFiles($sPath, $sFilter, $iRemDir = 0) Local $hSearch, $sFile $hSearch = FileFindFirstFile($sPath & "\" & $sFilter) If $hSearch = -1 Then If $iRemDir = 1 Then DirRemove($sPath) SetError(1) Return 0 EndIf While 1 $sFile = FileFindNextFile($hSearch) If @error = 1 Then If $iRemDir = 1 Then DirRemove($sPath, 0) SetError(0) Return 1 EndIf If $sFile = ".." Or $sFile = "." Then ContinueLoop $sFile = $sPath & "\" & $sFile If StringInStr(FileGetAttrib($sFile), "D") Then _DeleteFiles($sFile, "*", 1) ContinueLoop EndIf FileDelete($sFile) WEnd EndFuncalso check :http://www.autoitscript.com/forum/index.php?showtopic=27603http://www.autoitscript.com/forum/index.php?showtopic=45933 Projects : Space Regain - Memory Fusion - PWGT - Chip-ITGames : BrainPain - BrainPain Director's Cut - ProSpeed Games Pack (New)Vista vs XP : the forbidden fight
Caaio Posted July 9, 2007 Author Posted July 9, 2007 Thanks for the support mrbond007. I copy your code and it`s worked fine. But I would like to understand what your script is doing, i start to study it but i have some question about that. As I said, i`m new user and i would like to learn more to how to program on it. I would like to understand this: $hSearch = FileFindFirstFile($sPath & "\" & $sFilter) You didn`t declareted the $sPath and $sFilter. So, how AutoIT will know wich files will search? Thanks fow who can help me. Regards.
mrbond007 Posted July 9, 2007 Posted July 9, 2007 when you call _DeleteFiles(@TempDir, "*.*", 1) the $sPath will be @TempDir and the $sFilter will be "*.*" Projects : Space Regain - Memory Fusion - PWGT - Chip-ITGames : BrainPain - BrainPain Director's Cut - ProSpeed Games Pack (New)Vista vs XP : the forbidden fight
MHz Posted July 9, 2007 Posted July 9, 2007 If $sFile = ".." Or $sFile = "." Then ContinueLoopThat is line is not required. FileFindNextFile() has not returned ".." or "." for a long time. They were removed many versions ago. Just remove the line from the code as it does nothing useful.
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