Jump to content
Sign in to follow this  
nanodroid

Temp File Remove Tool

Recommended Posts

nanodroid

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

Posted Image

Share this post


Link to post
Share on other sites
BrewManNH

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 Gude
How 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

Share this post


Link to post
Share on other sites
nanodroid

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.

Share this post


Link to post
Share on other sites
Chimaera

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 8

Delete Cookies:

RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 2

Delete History:

RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 1

Delete Form Data:

RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 16

Delete Passwords:

RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 32

Delete All:

RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 255

Delete All + files and settings stored by Add-ons:

RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 4351

Share this post


Link to post
Share on other sites
Unsigned

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. :graduated:

Edited by Unsigned

.

Share this post


Link to post
Share on other sites
nanodroid

Ok unsigned so how would you write this script......in regards to bypassing the" ~DF77AB.tmp" that the script is stopping on.

Share this post


Link to post
Share on other sites
BrewManNH

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 Gude
How 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

Share this post


Link to post
Share on other sites
nanodroid

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.

Share this post


Link to post
Share on other sites
Unsigned

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.


.

Share this post


Link to post
Share on other sites
nanodroid

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)

Share this post


Link to post
Share on other sites
Unsigned

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 by Unsigned

.

Share this post


Link to post
Share on other sites
ripdad

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

Share this post


Link to post
Share on other sites
nanodroid

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")

Share this post


Link to post
Share on other sites
nanodroid

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!!!!!!

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  

×