Page 1 of 2 12>
Topic Options
#112130 - 2004-01-20 11:05 PM Recycle bin sample script
rvdmast Offline
Fresh Scripter

Registered: 2003-07-01
Posts: 15
; Recycle bin sample script uses a COM object to work
; with the recycle bin.
; Requires BinManager.dll to be installed on the system,
; see http://www.cheztabor.com/binmanager/

Dim $bin, $items, $size

$bin = CreateObject("BinManager.RecycleBin")
$items = $bin.NumItems
$size = $bin.Size

? "RecycleBin contains " $items " items " $size " bytes"
; Permanently delete items recycled more than two days ago.
; Note, the argument is full calendar days, so specifying
; zero would delete all items older than today.
$Returnvalue = $bin.DeleteOldItems(2)
; This permanently deletes all recycled items.
$Returnvalue = $bin.Empty()

Top
#112131 - 2004-01-20 11:37 PM Re: Recycle bin sample script
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11163
Loc: Boston, MA, USA
No need for COM DLLs as this could be done via pure KiXtart (optionally with WMI COM).
_________________________
There are two types of vessels, submarines and targets.

Top
#112132 - 2004-01-20 11:46 PM Re: Recycle bin sample script
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22344
Loc: OK
I knew I had code for this.
I didn't find my COM code but here is my simple version:
http://www.kixtart.org/ubbthreads/showflat.php?Cat=&Board=UBB1&Number=26421
_________________________
!

download KiXnet

Top
#112133 - 2004-01-21 12:11 AM Re: Recycle bin sample script
rvdmast Offline
Fresh Scripter

Registered: 2003-07-01
Posts: 15
Really? dont recall reading about the recycle bin in the KiX doc's. Could you give an example?
I'm not too good at WMI either...

Top
#112134 - 2004-01-21 12:13 AM Re: Recycle bin sample script
rvdmast Offline
Fresh Scripter

Registered: 2003-07-01
Posts: 15
btw what has Lonkero's link have to do with this?
Top
#112135 - 2004-01-21 03:01 AM Re: Recycle bin sample script
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11163
Loc: Boston, MA, USA
Why should the KiXtart documentation contain anything about the 'Recycle bin'? The 'Recycle Bin' is just a redirection from the RECYCLER subfolder that exists on the root directory of local drives, e.g. C:\RECYCLER. The RECYCLER subfolder contains numerous subfolder with the user's SID containing the user's deleted files. One can thus enumerate the folders/files via Kixtart and/or WMI/WSH and selectively delete them. However, two file sneed to preserved, namely 'desktop.ini' and the catalog file 'INFO2'.

This would also work but I beleive it will throw a prompt:
Code:

$sh = CreateObject("Shell.Application")
$fi = $sh.NameSpace(&h000a)
if $fi.items.count
$fi.ParentFolder.ParseName('::{645FF040-5081-101B-9F08-00AA002F954E}').InvokeVerb('Empty Recycle &Bin')
end if


See also http://www.microsoft.com/technet/treeview/default.asp?url=/technet/scriptcenter/scrguide/sas_fil_higv.asp

Using a custom DLL requires this DLL to be distributed to all computers and installed under admin privs.


Edited by sealeopard (2004-01-21 11:06 PM)
_________________________
There are two types of vessels, submarines and targets.

Top
#112136 - 2004-01-21 09:45 PM Re: Recycle bin sample script
rvdmast Offline
Fresh Scripter

Registered: 2003-07-01
Posts: 15
Quote:

However, two file sneed to preserved, namely 'desktop.ini' and the catalog file 'INFO2'.



Wich exactly why i didnt want to simply delete all files in the recycler folder, thereby possibly corrupting the recycle bin's functionality. Plus, i'd have to check for and delete the files on each logical drive.
But thx for that little script sample, i'll look into that.
As said i'm not much into WMI scripts (yet)

Top
#112137 - 2004-01-21 09:57 PM Re: Recycle bin sample script
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22344
Loc: OK
well, gladly there is no WMI scripts in this thread yet.
_________________________
!

download KiXnet

Top
#112138 - 2004-01-21 11:07 PM Re: Recycle bin sample script
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11163
Loc: Boston, MA, USA
WMI is just one option to solve the underlying problem of removing files from the RECYCLER subfolders. However, AFAIK, there's now WMI way to control the Recycle Bin.
_________________________
There are two types of vessels, submarines and targets.

Top
#112139 - 2006-02-16 10:16 AM Re: Recycle bin sample script
masken Offline
MM club member
*****

Registered: 2000-11-27
Posts: 1222
Loc: Gothenburg, Sweden
Rooting up an old thread, but how would one easily PUT items in the script executioners recycle bin (instead of hard deleting)? Ie, "delete to recycle bin"?

Edited by masken (2006-02-16 10:17 AM)
_________________________
The tart is out there

Top
#112140 - 2006-02-16 06:21 PM Re: Recycle bin sample script
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11616
Loc: CA
Well I replied in your Suggestions post too, but I'd like a KiXtart NATIVE way to deal with the Recycle Bin as well and not just delete to Recycle Bin.

Using other methods that require installation of a DLL are possible but cumbersome, which is why most of us use KiXtart in the first place as it makes all these tasks so much easier to do.

Top
#112141 - 2006-02-16 06:55 PM Re: Recycle bin sample script
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Can this VBA snippet be converted?
http://www.cpearson.com/excel/Recycle.htm
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#112142 - 2006-02-16 06:57 PM Re: Recycle bin sample script
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
or this... I can't remember if kix support "InvokeVerb"

Option Explicit
Dim oWinShell, oSHFolder, oSHFItems, oSHFItem
Dim Start
msgbox "Go..."
start = csng(timer)
Set oWinShell = CreateObject("Shell.Application")
Set oSHFolder = oWinShell.Namespace("C:\")


Set oSHFItems = oSHFolder.Items
Set oSHFItem = oSHFItems.Item("temp.txt")
oSHFItem.InvokeVerb("&Delete")


Set oWinShell = Nothing
Set oSHFolder = Nothing
Set oSHFItems = Nothing
Set oSHFItem = Nothing
msgbox csng(timer) - start


--
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#112143 - 2006-02-16 06:58 PM Re: Recycle bin sample script
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11616
Loc: CA
Not directly with KiXtart but maybe a shell to VB script which then shells the API call.

I'm sure Ruud could implement something which is the point of recent discussion I suppose, unless Masken is wanting something a bit sooner in which case that may be a great link for him Les.


Why does the Recycle Bin have different file system names on FAT and NTFS?
http://blogs.msdn.com/oldnewthing/archive/2006/01/31/520225.aspx

Don't forget that KiXtart would also need to be aware of such programs as Norton Protected Recycle Bin and act accordingly.

Top
#112144 - 2006-02-16 07:01 PM Re: Recycle bin sample script
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11616
Loc: CA
Similar code that Jens posted a while back. Unless I'm mistaken here I don't think Masken was wanting or looking for a method to do it right now so much as I think he wanted an EASY way with a built-in command or function from KiXtart.

But if that's not the case and he is looking for immediate answer then I suppose all these work-arounds might be of immediate value for him.

Top
#112145 - 2006-02-16 07:01 PM Re: Recycle bin sample script
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
The FileAction() UDF will send to recyle bin but it prompts first.
Break On

$sFile="C:\test.txt"

$=FileAction($sFile,"Delete")
@ERROR " | " @SERROR ?

Get $
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#112146 - 2006-02-16 07:05 PM Re: Recycle bin sample script
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Oh, and FileAction() proves that InvokeVerb does in fact work in KiX.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#112147 - 2006-02-16 08:51 PM Re: Recycle bin sample script
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22344
Loc: OK
yes it does
_________________________
!

download KiXnet

Top
#112148 - 2006-02-16 10:15 PM Re: Recycle bin sample script
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Only prob, Jooel's version doesn't work, I need to use Chris' version.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#112149 - 2006-02-16 10:36 PM Re: Recycle bin sample script
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22344
Loc: OK
lol.
no, only problem is, xp sp2 doesn't work with my udf.
there is no problem in the udf
_________________________
!

download KiXnet

Top
Page 1 of 2 12>


Moderator:  Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 176 anonymous users online.
Newest Members
Quicky76, Tonny, Kelar18, korunekosama, Varro18
17783 Registered Users

Generated in 0.157 seconds in which 0.089 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org