Jump to content

Recycle Bin


Recommended Posts

This was often asked under version 2 (I never did see an answer that worked) and I just want to know if it has been resolved yet.

Is there a way to unconditionaly empty the RB? It's nice that we can now send files to the bucket but it would sure be nice to empty it as well and preferably with no dialogs popping up. The less user intervention the better is my motto.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

I haven't quite figured out the right way to do it, but here is one way:

I don't have AutoIt make many shortcuts, so I am not too familiar with how to make one for the recycle bin. But if you make a directory C:\empty, and place a shortcut to recycle bin from the desktop there, this works.

I have it clean out the bin (one file or many) and push all the confirmations, and then clean it self up.

If FileExists ( "C:\empty" ) then
Else
    DirCreate( "C:\empty" )
; I am not good at makeing shortcuts, please drag and drop shortcut to recycle bin in this folder
    FileCreateShortcut ( "Recycle Bin", "C:\empty\Recycle Bin.lnk", "Desktop","","Recycle Bin" ) 
endif

Run("explorer C:\empty")
WinWaitActive("C:\empty", "")
ControlFocus ("C:\empty", "", "SysListView321")
Send("Shortcut to Recycle Bin{APPSKEY}b")
WinWaitActive("Confirm","",5)
If WinExists ("Confirm Multiple File Delete","") then
ControlLeftClick ("Confirm Multiple File Delete", "Are you sure", "Button1")
Else
ControlLeftClick ("Confirm File Delete", "Are you sure", "Button1")
EndIf
WinClose("C:\empty")

AutoIt3, the MACGYVER Pocket Knife for computers.

Link to comment
Share on other sites

If you want to delete a file and not send it to recycle bin, why not use

FileDelete instead of

FileRecycle?

Anyway, I tried a few senarios. but without an external commandline program (which could be included in the compiled script) I wasn't having the best of luck.

AutoIt3, the MACGYVER Pocket Knife for computers.

Link to comment
Share on other sites

You don't have to do all that shortcut creation stuff. You can launch the Recycle Bin with this line:

Run("explorer ::{645FF040-5081-101B-9F08-00AA002F954E}")

After that, you can do the {APPSKEY}b bit.

Link to comment
Share on other sites

I was hoping to avoid even seeing that confirmation dialog. for Windows 9x systems I could just Deltree it and let a new one be built on the restart, which it has to do anyway. I was just hoping that Jon might have included an easy way in version 3 to handle it on all systems. I know there is a Windows API call fo it I forget now if it was the window handle or the entry point that I couldn't get. I would rather dump the 3rd party app that I have doing it now because that app is written in VB and I have this thing about the overhead that VB imposes on older systems. Not everybody wants to load the VB6 runtimes.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

you could always try this:

$x=FileFindFirstFile ( "c:\Recycler\*.*" )
While StringLeft($x,1)="."
$x=FileFindNextFile ( )  
WEnd
FileDelete ( "c:\Recycler\"&$x&"\*.*" ) 
DirRemove( "c:\Recycler\"&$x)
ClipPut("c:\Recycler\"&$x)

The first directory entry will return .

The second will be ..

The next one will have a bunch of numbers and dashes, and that will be $x.

I think you may get an access denied msg if you send read only files or something, but this would have no dialogs. Maybe you could expand on it.

I think you could use the commandline delete funtion, or just set all the files attributes to normal before doing it, but it gives you some thing to play around with.

Edit... If you delete some system file it may not work.

Edited by scriptkitty

AutoIt3, the MACGYVER Pocket Knife for computers.

Link to comment
Share on other sites

Nice try scriptkitty but it has some rather serious drawbacks.

I could do essentialy the same thing running

attrib -h -r -s c:\recycled\info*

filedelete ("c:\recycled\*.*)

That would unhide and delete the info2 file which is the file that tracks the RB restore information. It would then delete the files while still leaving the hidden desktop.ini file in place. It would also only work on the C:\ partition and it would leave the RB "full" icon in place. The user would have to then create a dummy file, delete it and empty the RB to get the icon starightened out. Running

%windir%\command\deltree /y c:\recycled\ avoids the icon problem but still leaves you with it only working on the specified partition. The way around that would be an array that retrieved all of the fixed drives (a possibility). The critical file (desktop.ini) will be recreated on the restart. While I am at it, do you know of any method that can be used to force a restart to Safe Mode? Thanks for your input here. I still think it would be easier for Jon to include the Empty RB function in the code. (that's a hint Jon) :whistle:

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

Yea, I don't think I even have a deltree on my system anymore, might have it hidden somewhere though (win2000,winXP.) Since I don't at least have it in my path, I didn't use that suggestion.

In testing it, I did notice a few recycle bin icon not updating, and figured there was an ini or reg entry that needed fixing. I couldn't find any problem other than astectics, so I posted up the script.

I do delete the folder, as in my systems, it rebuilds the second you place something in the recycle bin.

Well I may have gone as fas as I am willing to try scripting this with existing tools. :whistle:

Might be a good idea to place in the idea forrum. Or maybe it will get moved. B)

Oh yea, Happy New Year!!!!

AutoIt3, the MACGYVER Pocket Knife for computers.

Link to comment
Share on other sites

It was a brave effort. And I think Deltree is a thing of the past with XP. I could be wrong on that and if I get a chance I'll look for it. It's not all that important that it run on XP anyway since the issues I am trying to solve seem to only appear on the 9x kernel and not NT. I can always set the installer so it will only install below version 5 Windows and then I don't have to worry about XP/2000 at all. Like you say, maybe Jon will pick up on the hint.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

I'll Take a look at this one. I used a third party tool in the last version but it was written in VB6 and I don't like imposing any VB on the user. It seems ridiculous to have them install the runtimes for such a simple function.

maybe also see here

This is out! The Windows Clean Manager had a real nasty habit of breaking the RB totally :whistle: . I have responded to enough queries on the MS newsgroups about this particular problem. I don't want to generate any more aggrivation over it B).

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

Thanks Jon. That means that I could, if necessary, use Deltree to do it. It's still kind of an ugly work around though.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

Have you tried to use

"del c:\recycler /s /f /q"

Forces deletion of all files in all directories below c:\recycler without prompting.

For more info just type "del /?" at a command prompt

Cheers

Nobby

CheersNobby

Link to comment
Share on other sites

It still only does the Bin on the specified drive and I think it will miss the info2 file (which is hidden) and that one is critical.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

If you're willing to accept dialog boxes flashing up but using the script to manage them then the following script should meet your requirements that no user input is required.

I've only tested it on Win2000 but it should work on other OSes as well. Its not totally bullet proof

;
; AutoIt Version: 3.0
; Language:       English
; Platform:       Win2000
; Author:         Graham Shanks
;
; Script Function:
;   Empty the recycle bin
;

run(@WindowsDir & "\explorer.exe")

; Explorer starts in the My Documents directory
WinWaitActive("My Documents")

; Move up to the Desktop
send("{LEFT}")
WinWaitActive("Desktop")

; This assumes that the only sub-element of the Desktop is the Recycle Bin
send("R")
WinWaitActive("Recycle Bin")

; Check that the Recycle Bin is not empty (if it is then there is nothing to do)
$text = StatusbarGetText("Recycle Bin")
If $text <> "0 Object(s)" Then

   ; Empty the Recycle Bin
    send("!FB")

   ; File Delete popup - Could be either "Confirm File Delete" or "Comfirm Multiple File Delete"
    AutoItSetOption("WinTitleMatchMode", 2)
    WinWaitActive("File Delete")
    send("y")

   ; Wait until the bin is empty 
    While "0 Object(s)" <> StatusbarGetText("Recycle Bin")
        Sleep(250)
    WEnd
EndIf
WinClose("Recycle Bin")

GrahamS

Link to comment
Share on other sites

  • 6 years later...

Run(@ComSpec & " /c " & 'attrib X:\$RECYCLE.BIN -s -h -r', "", @SW_HIDE)

Run(@ComSpec & " /c " & 'del X:\$RECYCLE.BIN /s /f /q', "", @SW_HIDE)

RegWrite("HKEY_USERS\.DEFAULT\Software\Microsoft\Windows\CurrentVersion\Explorer\CLSID\{645FF040-5081-101B-9F08-00AA002F954E}\DefaultIcon", "", "REG_EXPAND_SZ", "%SystemRoot%\System32\imageres.dll,-55")

Sleep (100)

ControlSend('Program Manager', '', '', '{F5}')

ControlSend('Program Manager', '', '', '{F5}')

Link to comment
Share on other sites

Thanks a million for dragging up a 6 year old post.

BTW: Have you tried this?

Run(@ComSpec & " /c " & 'attrib X:\$RECYCLE.BIN ...', "", @SW_HIDE)

"..." should remove all attribs when using the command interpreter. I haven't tried it using the AutoIt FileSetAttrib() but I strongly suggest that it won't work.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...