|
|
|||||||
; 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() |
||||||||
|
|
|||||||
No need for COM DLLs as this could be done via pure KiXtart (optionally with WMI COM). |
||||||||
|
|
|||||||
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 |
||||||||
|
|
|||||||
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... |
||||||||
|
|
|||||||
btw what has Lonkero's link have to do with this? |
||||||||
|
|
|||||||
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:
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. |
||||||||
|
|
|||||||
Quote: 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) |
||||||||
|
|
|||||||
well, gladly there is no WMI scripts in this thread yet. |
||||||||
|
|
|||||||
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. |
||||||||
|
|
|||||||
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"? |
||||||||
|
|
|||||||
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. |
||||||||
|
|
|||||||
Can this VBA snippet be converted? http://www.cpearson.com/excel/Recycle.htm |
||||||||
|
|
|||||||
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 -- |
||||||||
|
|
|||||||
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. |
||||||||
|
|
|||||||
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. |
||||||||
|
|
|||||||
The FileAction() UDF will send to recyle bin but it prompts first. Break On $sFile="C:\test.txt" $=FileAction($sFile,"Delete") @ERROR " | " @SERROR ? Get $ |
||||||||
|
|
|||||||
Oh, and FileAction() proves that InvokeVerb does in fact work in KiX. |
||||||||
|
|
|||||||
yes it does |
||||||||
|
|
|||||||
Only prob, Jooel's version doesn't work, I need to use Chris' version. |
||||||||
|
|
|||||||
lol. no, only problem is, xp sp2 doesn't work with my udf. there is no problem in the udf |
||||||||
|
|
|||||||
yeah, working with DLL's and calling other script languages isn't really KiX:ing, is it? This seems like an elementary function that really should be supported natively if you ask me... @NTDOC, I don't think the system needs to be aware of the Norton thing, if so, every application written for win would need to be aware of different AV-functions. I think it works on another level? |
||||||||
|
|
|||||||
k, lets get the facts straight a little bit. starting from binmanager. that dll is nothing more but shell object wrapper and thus totally unneeded for this. and what comes to recygle bin being something a scripting language should support natively. eh, lets start by someone showing a scripting language that already does. recycle bin is a gui undo helper for helpless end-users. so why would any scripter want to say, "hey, I'm helpless and don't know wtf I'm doing, please give me undo!" and, "please do place the files in the recycle bin, so my end users can also see that I do write scripts but I have no idea what I'm doing, so they can laught at me." it just doesn't make any sense. |
||||||||
|
|
|||||||
You can't just generalize like that m8... for me, a function like this natively makes ALOT of sense. It all depends on what you're doing with the script. And since KiX is more of a general sysadmin processor than a login script processor, it makes even more sense. Let's say you have a script that empties a folder with any given interval. Maybe one would want backup for that. Let's say you've got a KiXform application which has delete-functionality in it. Let's say an end-user has been assigned a script by a sysadmin with a del-function in it. Lot's of usability. |
||||||||
|
|
|||||||
you saying that you would like to have your recycle bin act as backup folder? come on man. |
||||||||
|
|
|||||||
well that's it's sole purpose and why it's there in the first place, so yes. |