nanodroid Posted September 30, 2011 Share Posted September 30, 2011 I'm trying to creat a script that will remove "temp" files form PC. Here is the script so far: Send("#r")Send("%Temp%")WinWaitActive("Run","Type the name of a program")send("{TAB}")send("{Enter}")WinWaitActive("Temp","\LOCALS~1\Temp")Send("{CTRLDOWN}a{CTRLUP}{DEL}")WinWaitActive("Confirm Multiple File Delete","Are you sure you want to send")Send("{Enter}")WinWaitActive("Error Deleting File or Folder","Cannot delete") This is not the exact error but very close, in the middle of the msgbox its says: ~DF77AB.tmp Link to comment Share on other sites More sharing options...
BrewManNH Posted September 30, 2011 Share Posted September 30, 2011 And your question is...? If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
nanodroid Posted September 30, 2011 Author Share Posted September 30, 2011 My question is how do I get the script to skip or bypass the "error message" that I'm getting. An then proceed with the clean up of the temp file. Link to comment Share on other sites More sharing options...
Unsigned Posted September 30, 2011 Share Posted September 30, 2011 First of all, don't use Send commands for a job like this, please. Hacky attempt to do something that could EASILY be done via the API. Have a look at FileChangeDir, FileFindFirstFile, FileFindNextFile, FileDelete . Link to comment Share on other sites More sharing options...
Chimaera Posted September 30, 2011 Share Posted September 30, 2011 At a guess something is using the file and thats whats blocking you, certain programs use temp files that way Try copying one of these Rundll32 commands into the run box and see if they complete. Maybe you can use them with RunWait() or similar Delete Temporary Internet Files:RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 8Delete Cookies:RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 2Delete History:RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 1Delete Form Data:RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 16Delete Passwords:RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 32Delete All:RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 255Delete All + files and settings stored by Add-ons:RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 4351 If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices() Link to comment Share on other sites More sharing options...
Unsigned Posted September 30, 2011 Share Posted September 30, 2011 (edited) At a guess something is using the file and thats whats blocking you, certain programs use temp files that way Try copying one of these Rundll32 commands into the run box and see if they complete. Maybe you can use them with RunWait() or similar Alternatively, use DllCall directly. RUNDLL32.EXE is just a wrapper for calling a DLL, which AutoIt provides natively. Edited September 30, 2011 by Unsigned . Link to comment Share on other sites More sharing options...
nanodroid Posted September 30, 2011 Author Share Posted September 30, 2011 Ok unsigned so how would you write this script......in regards to bypassing the" ~DF77AB.tmp" that the script is stopping on. Link to comment Share on other sites More sharing options...
BrewManNH Posted September 30, 2011 Share Posted September 30, 2011 If you get a list of files in the temp folder (use _RecFileListToArray.au3 UDF), loop through the array deleting the files one at a time, if you get a file that you can't delete, and there will be many I'll guess, ignore the error and go to the next one in the list. Eventually you'll end up with just the files that can't be deleted. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
nanodroid Posted September 30, 2011 Author Share Posted September 30, 2011 Brew thanks for the help I understand the concept of yous answer. But being that I'm a novice at Autoit and scripting as altogether. I wonder if you can point me to a site that might help me with the understanding of how the (_RecFileListToArray.au3 UDF) works. And also the "loop through "Arrays" this would be very helpful to me...thanks. Link to comment Share on other sites More sharing options...
Unsigned Posted September 30, 2011 Share Posted September 30, 2011 And also the "loop through "Arrays"... How about reading the tutorials & documentation and learn the basics of scripting before asking somebody to re-write it all here for you. . Link to comment Share on other sites More sharing options...
nanodroid Posted October 7, 2011 Author Share Posted October 7, 2011 Unsigned, thanks for the great information on the "FileFind" documentation: As a reminder I'm a novice but I took your advice on just going through some of the tutorials that Autoit has. I attempted to try one on my own, this script is suppose to Go to my desktop and open a test folder I created, and delete a .txt file inside. I used your technique of useing the "File" commands in autoit but it is not working. Can you take a look at the script just to make sure that I'm writing it correctly....don't give me the answer just point me in the right direction. Here it is..... #include <file.au3> FileChangeDir(@DesktopDir) $search = FileFindFirstFile("Test Todd") If $search = -1 Then MsgBox(0, "Error", "No files/directories matched the search pattern") Exit EndIf While 1 $file = FileFindNextFile($search) If @error Then ExitLoop MsgBox(4096, "File:", $file) WEnd ; Close the search handle FileClose($search) FileDelete($search) Link to comment Share on other sites More sharing options...
Unsigned Posted October 8, 2011 Share Posted October 8, 2011 (edited) Firstly, use the [ autoit ] [ /autoit ] tags to post your code, its much more readable. That said, you do not need to FileDelete $search. It's a virtual handle to the search state, it doesn't actually reference an on-disk file. Just call FileClose to signal AutoIt that you're done with it. I'd also capitalize <File.au3>, but that's just me, Windows references local filesystems case-insensitively so it shouldn't really matter. What exactly doesn't work? Edited October 8, 2011 by Unsigned . Link to comment Share on other sites More sharing options...
ripdad Posted October 8, 2011 Share Posted October 8, 2011 nanodroid, replace with this ... $search = FileFindFirstFile(@DesktopDir & "\Test Todd\*") Even if you FileChangeDir (which is not needed here) ... you still need to enter the proper path for FileFindFirstFile. "The mediocre teacher tells. The Good teacher explains. The superior teacher demonstrates. The great teacher inspires." -William Arthur Ward Link to comment Share on other sites More sharing options...
nanodroid Posted October 11, 2011 Author Share Posted October 11, 2011 Unsigned, thanks for the tips on this script, I took your advice and and fixed the mistakes that where in it: See script below....it works. But how do I make the script work for all users instead of the actual user at that time. See line 14 #include <File.au3> FileChangeDir(@DesktopDir) $search = FileFindFirstFile("Test Todd") ; Check if the search was successful If $search = -1 Then MsgBox(0, "Error", "No files/directories matched the search pattern") Exit EndIf While 1 $file = FileFindNextFile($search) If @error Then ExitLoop MsgBox(4096, "File:", $file) WEnd FileDelete("C:\Documents and Settings\twilson\Desktop\Test Todd") Link to comment Share on other sites More sharing options...
Unsigned Posted October 12, 2011 Share Posted October 12, 2011 (edited) Use this:FileDelete(@DesktopDir & "\Test Todd") Edited October 12, 2011 by Unsigned . Link to comment Share on other sites More sharing options...
nanodroid Posted October 12, 2011 Author Share Posted October 12, 2011 Unsigned, you are the man thanks you just helped me with my first successful script....I hope you get signed one day so that we can call you SIGNED!!!!!! Link to comment Share on other sites More sharing options...
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