Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Empty Recycle bin

198 views
Skip to first unread message

Dom Ciccotto

unread,
Aug 12, 2002, 11:31:12 PM8/12/02
to
How can I script the emptying of the recycle bin.

Thanks
Dom Ciccotto

arvaco

unread,
Aug 13, 2002, 10:44:29 AM8/13/02
to
Just to take a stab at this, couldn't you use a filesystem object to
cycle through the recycle bin and delete all the files including the INFO2
file?
Seems to me that when you delete a file and it's "sent" to the recycle
bin the file never actually "moves" just the file allocation table (FAT) is
updated to show that the file now belongs to the recycle bin and the name of
the file is changed to DC0.txt, DC1.jpeg, DC2.xml and so on. I would assume
that all previous FAT information about the file is stored in INFO2 (INFO2
is created as soon as a file is "sent" to the recycle bin). If you delete
these files all that takes place is the reference to them in the FAT is
removed and bingo, no more files. Well no more files as far as the operating
system is concerned the actual file won't truely be gone until such a time
that it is written over by some other file or process.
Hope this helps;
Kev

"Dom Ciccotto" <DomCi...@aol.com> wrote in message
news:44%59.159872$yc3.6...@bin4.nnrp.aus1.giganews.com...

Joe Earnest

unread,
Aug 13, 2002, 12:59:45 PM8/13/02
to
Try this:

Set oShellApp= WScript.CreateObject("Shell.Application")
Set oRecycleBin= oShellApp.Namespace(15)
oRecycleBin.InvokeVerb "Empty Recycle &Bin"

(I got this from a MVP post here, but I can't recall who. Sorry for bad
crediting.)

Regards,
Joe Earnest

"Dom Ciccotto" <DomCi...@aol.com> wrote in message
news:44%59.159872$yc3.6...@bin4.nnrp.aus1.giganews.com...

arvaco

unread,
Aug 13, 2002, 6:31:02 PM8/13/02
to
Why do I get errors on this... "Line 3 char 1 Object required: oRecycleBin"

"Joe Earnest" <joeea...@qwest.net> wrote in message
news:#vd0wpuQCHA.2632@tkmsftngp10...

guy

unread,
Aug 13, 2002, 8:21:59 PM8/13/02
to
' this works for me
Const myDesktop = 0
Set oShellApp = WScript.CreateObject("Shell.Application")
Set oDesktop = oShellApp.Namespace(myDesktop)
WScript.Echo("Listing of Folders on my Desktop")
For Each FolderItem In oDesktop.Items
WScript.Echo(FolderItem.Name)
If FolderItem.Name = "Recycle Bin" Then
set FolderItemVerbs = FolderItem.Verbs
For Each FolderItemVerb In FolderItemVerbs
WScript.Echo(">> Recycle Bin Folder has these verbs " &
FolderItemVerb.Name)
Next
FolderItem.InvokeVerb "Empty Recycle &Bin"
End if
Next

arvaco

unread,
Aug 13, 2002, 9:07:00 PM8/13/02
to
Now that's slick :) I did get an error on this line:

WScript.Echo(">> Recycle Bin Folder has these verbs " & FolderItemVerb.Name)
in the one loop, computer seems to have a problem with FolderItemVerb.Name,
but I have been trying to get a clearer picture of InvokeVerb. Thanks guy.

"guy" <g...@hotmail.com> wrote in message
news:3h8jlu0fj69djr1tt...@4ax.com...

Fosco

unread,
Aug 14, 2002, 1:32:29 AM8/14/02
to
"Dom Ciccotto"

> How can I script the emptying of the recycle bin.

Recycled >>>Recycler
Change Invoke verb"" right click on c:\recycled
in a English OS may be "&Empty..???"


Const ssfDRIVES = &H11
Set oSH = CreateObject("Shell.Application")
'oSH.NameSpace(ssfDRIVES).ParseName("C:\RECYCLED").InvokeVerb "Open"

oSH.NameSpace(ssfDRIVES).ParseName("C:\RECYCLED").InvokeVerb "S&vuota cestino"
--
Fosco


Jerry

unread,
Aug 14, 2002, 8:32:22 PM8/14/02
to
This works for me.

'Empty Recycle Bin if it has anything in it.

Const ssfDESKTOP = 0
For Each oShFolderItem In oShFolder.Items
If oShFolderItem.Name = "Recycle Bin" Then
oShFolderItem.InvokeVerb("Empty Recycle &Bin")
Exit For
End If
Next

Jerry

"Fosco" <fa...@fake.it> wrote in message
news:NXl69.64461$lu5.1...@twister1.libero.it...

Todd Vargo

unread,
Aug 14, 2002, 11:51:04 PM8/14/02
to
The InvokeVerb seems to work well in these scripts. But, does anyone know
why the other script fails for listing the verbs?

--
Todd Vargo (body of message must contain my name to reply by email)


"Jerry" <je...@hotmail.com> wrote in message
news:qEC69.285199$q53.9...@twister.austin.rr.com...

Todd Vargo

unread,
Aug 16, 2002, 5:28:12 PM8/16/02
to
I got the same error (but nobody seems to be responding to my reply to
Jerry's post). I just can not figure out why FolderItemVerb.Name fails in a
.vbs file. Does anyone know?

--
Todd Vargo (body of message must contain my name to reply by email)


"arvaco" <lo...@that.com> wrote in message
news:Ofwau9yQCHA.4284@tkmsftngp09...

Gurgen

unread,
Aug 16, 2002, 6:50:28 PM8/16/02
to
It fails on NT but works fine on W2K if used in vbscript.
I suppose it is a FolderItemVerb type property bug in NT version of shell32.
This property *does* work in VB project if object explicitly declared as
"FolderItemVerb".

Moreover, the name of "Recycle Bin" can be changed and be different on the
desktop. I found a version that relied on class:
------------------------------------------------------------------------
Set oShell = CreateObject("Shell.Application")
Const CLSID = "::{645FF040-5081-101B-9F08-00AA002F954E}"
Set Folder = oShell.Namespace(0).ParseName(CLSID)
Folder.InvokeVerb "Empty Recycle &Bin"
------------------------------------------------------------------------
--
Gurgen Alaverdian
http://www.gurgensvbstuff.com
"Todd Vargo" <todd...@nccw.net> wrote in message
news:edysewWRCHA.1756@tkmsftngp11...

Jerry

unread,
Aug 17, 2002, 12:12:30 AM8/17/02
to
Here is the rest of it. Take out what you dont need. But for now put it all
in a vbs file and try it. Works for me, but I only use W2K.

Dim filesys
Dim wshShell
Dim NewFolder
Dim RegKey
Dim ScreenSaver
Dim Result


Set filesys = CreateObject("Scripting.FileSystemObject")
Set wshShell = wscript.Createobject("wscript.shell")
Set WshShell = CreateObject("WScript.Shell")
Set WshNetwork = WScript.CreateObject("WScript.Network")
Set Shell = CreateObject("WScript.Shell")
Set objShell = WScript.CreateObject("WScript.Shell")


Set oShell = CreateObject("Shell.Application")

Set oShFolder = oShell.Namespace(ssfDESKTOP)


Const ssfDESKTOP = 0
For Each oShFolderItem In oShFolder.Items
If oShFolderItem.Name = "Recycle Bin" Then
oShFolderItem.InvokeVerb("Empty Recycle &Bin")
Exit For
End If
Next


set filesys = Nothing
set wshshell = Nothing
set WshNetwork = Nothing
set NewFolder = Nothing
set objShell = Nothing
Set oShell = Nothing
Set oShFolder = Nothing


"Gurgen" <gur...@bellatlantic.net> wrote in message
news:Ukf79.2462$l62....@nwrddc02.gnilink.net...

Fosco

unread,
Aug 17, 2002, 9:49:48 AM8/17/02
to
"Jerry"

YES...
But the most interesting part of all this thread is:
WScript.Echo("Recycle has these verbs " &FolderItemVerb.Name)

It fails also on Win98....
--
Fosco


guy

unread,
Aug 17, 2002, 10:21:34 AM8/17/02
to
Any diagnostics reported with the failure?
use the err object if nothing else

What version of shell32.dll?
locate shell32.dll on the path, system32 folder for me
look at the version properties

Gurgen

unread,
Aug 17, 2002, 1:45:53 PM8/17/02
to
As I suspected it is a bug (in 4.72.3612.1700 at list) . Michael Harris has
done research in the past:
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&threadm=unMc4QdW%23GA.209
%40uppssnewspub05.moswest.msn.net&rnum=5&prev=/groups%3Fsourceid%3Dnavclient
%26q%3DFolderItemVerb%2BVBscript

"guy" <g...@hotmail.com> wrote in message

news:ommslusvtpov2fm3o...@4ax.com...

Todd Vargo

unread,
Aug 17, 2002, 3:54:59 PM8/17/02
to

"Jerry" <je...@hotmail.com> wrote in message
news:O2k79.95991$Yd.43...@twister.austin.rr.com...

> Here is the rest of it. Take out what you dont need. But for now put it
all
> in a vbs file and try it. Works for me, but I only use W2K.
>
> Dim filesys
> Dim wshShell
> Dim NewFolder
> Dim RegKey
> Dim ScreenSaver
> Dim Result

"the rest of it", hmmm. ;-)

>
>
> Set filesys = CreateObject("Scripting.FileSystemObject")
> Set wshShell = wscript.Createobject("wscript.shell")
> Set WshShell = CreateObject("WScript.Shell")

What's the difference between the two WshShell lines above? Do they actually
set WshShell with different objects? I assume they are both the same, but
figured I better ask to be sure.


> Set WshNetwork = WScript.CreateObject("WScript.Network")
> Set Shell = CreateObject("WScript.Shell")
> Set objShell = WScript.CreateObject("WScript.Shell")
> Set oShell = CreateObject("Shell.Application")
> Set oShFolder = oShell.Namespace(ssfDESKTOP)

Why do you need to create so many WScript.Shell objects? I assume it's for
pasting other peoples unmodified code into yours, but one never knows.

>
>
> Const ssfDESKTOP = 0
> For Each oShFolderItem In oShFolder.Items
> If oShFolderItem.Name = "Recycle Bin" Then
> oShFolderItem.InvokeVerb("Empty Recycle &Bin")
> Exit For
> End If
> Next

How does this code help me understand why "_Verb.Name" is failing?

Todd Vargo

unread,
Aug 17, 2002, 3:57:14 PM8/17/02
to

"Fosco" <fa...@fake.it> wrote in message
news:0ws79.72979$lu5.2...@twister1.libero.it...

Exactly! I'm using Win98/IE6 and the problem code specifically is
"FolderItemVerb.Name". As I mentioned, ".InvokeVerb" works fine, but I
wanted to expose all available actions for examination.

Well, from reading Michael Harris' post from 1999, I deduce that this is a
bug, but has it ever been fixed? Considering I've upgraded IE/WSH twice
since 1999, I guess not.

Jerry

unread,
Aug 17, 2002, 5:14:17 PM8/17/02
to
No difference, in wshshell lines. I made a template so I don't have to type
in the same things over and over and copied this twice. That is why you see
some things unrelated to the code at hand. Also, this is from a larger
script I put together to tune up a system and is just a small part.
I kill everything with a set = nothing at the end so I don't see a problem
with using unrelated code on some of the things I put together.
Yes, the more unmodified, the better. :)

"Todd Vargo" <todd...@nccw.net> wrote in message

news:Obq65piRCHA.2684@tkmsftngp08...

Michael Harris (MVP)

unread,
Aug 17, 2002, 5:32:39 PM8/17/02
to
> Well, from reading Michael Harris' post from 1999, I deduce that this is a
> bug, but has it ever been fixed? Considering I've upgraded IE/WSH twice
> since 1999, I guess not.

It *has* been fixed in OS versions with newer versions of shell32.dll. Upgrading IE and/or WSH on Win98 doesn't upgrade shell32.dll, only an OS upgrade to Win2000/WinXP will solve your problem.

--
Michael Harris
Microsoft.MVP.Scripting
Seattle WA US
--

Todd Vargo

unread,
Aug 17, 2002, 10:13:43 PM8/17/02
to

"Michael Harris (MVP)" <mik...@mvps.org> wrote in message
news:euut5VjRCHA.4228@tkmsftngp08...

>> Well, from reading Michael Harris' post from 1999, I deduce that this is
a
>> bug, but has it ever been fixed? Considering I've upgraded IE/WSH twice
>> since 1999, I guess not.
>
> It *has* been fixed in OS versions with newer versions of shell32.dll.
> Upgrading IE and/or WSH on Win98 doesn't upgrade shell32.dll, only an OS
> upgrade to Win2000/WinXP will solve your problem.

Michael,

That was what I needed to know, thanks.

Well, I checked and sure enough, there was a patch that updated shell32.dll
to version 4.72.3812.600, but it did not address this problem.

Well, since Win98 is supposedly to still be supported, and this was reported
back in 1999, this trivial bug should have been fixed for Win98 long ago.
Stuff like this makes one wonder what other non-security related bug reports
are being ignored for "supported" software. :(

Q. What do call an upgrade from one lemon to another.
A. A sour refreshment. :-D

Gurgen

unread,
Aug 18, 2002, 1:03:33 AM8/18/02
to
This is so annoying. I had to write a small patch. It requires object
registration though:
http://www.gurgensvbstuff.com/Zips/SHVerbPatch.zip

The object properly invokes "Name" property and executes "Dolt" on Win9x
and WinNT.

Converted example is shown:
--------------------------------------------------------


Const myDesktop = 0
Set oShellApp = WScript.CreateObject("Shell.Application")

'Create a patch object
Set oVerb = CreateObject("ShellPatch.VerbPatch")


Set oDesktop = oShellApp.Namespace(myDesktop)
WScript.Echo("Listing of Folders on my Desktop")
For Each FolderItem In oDesktop.Items
WScript.Echo(FolderItem.Name)
If FolderItem.Name = "Recycle Bin" Then
set FolderItemVerbs = FolderItem.Verbs
For Each FolderItemVerb In FolderItemVerbs

'Get verb Name
vName = oVerb.VerbName(FolderItemVerb)
Wscript.Echo vName
If vName = "Empty Recycle &Bin" then
'Invoke verb
oVerb.VerbDolt FolderItemVerb
End If
Next
End if
'FolderItem.InvokeVerb "Empty Recycle &Bin"
Next
-------------------------------------------------------------

--
Gurgen Alaverdian
http://www.gurgensvbstuff.com
"Todd Vargo" <todd...@nccw.net> wrote in message

news:ect0V0lRCHA.1672@tkmsftngp12...

Fosco

unread,
Aug 18, 2002, 2:16:18 AM8/18/02
to
"guy"

> Any diagnostics reported with the failure?

Object doesn't support this property or method:'FolderItemVerb.Name'

> What version of shell32.dll?

4.72.3612.1700
( I just read ... bugs with this version)
--
Fosco

Fosco

unread,
Aug 18, 2002, 11:03:18 AM8/18/02
to
"Gurgen"

> This is so annoying. I had to write a small patch. It requires object
> registration though:
> http://www.gurgensvbstuff.com/Zips/SHVerbPatch.zip


YES it works ..
--
Fosco


0 new messages