Alaska Software Inc. - Erase and FErase
Username: Password:
AuthorTopic: Erase and FErase
Itai Ben-ArtziErase and FErase
on Thu, 25 Jun 2020 23:54:04 -0700
Both, Erase and FErase permanently and irreversibly delete a file.  Is
there a command or parameter that move a file to the Recycle Bin so a
user may restore it?
Many thanks,
-Itai
Jonathan LeemingRe: Erase and FErase
on Fri, 26 Jun 2020 12:39:22 -0600
On 6/26/2020 12:54 AM, Itai Ben-Artzi wrote:
> Both, Erase and FErase permanently and irreversibly delete a file.  Is
> there a command or parameter that move a file to the Recycle Bin so a
> user may restore it?
> Many thanks,
> -Itai
> 
Hi Itai,

I don't know of a way to do this with a native MS Dos command however I 
found a free utility called recycle.exe that allows one to delete a file 
to the recycle bin and also restore from the recycle bin.  I just 
downloaded it and it appears to work as "advertised".

Download Link: https://www.downloadcrew.com/download/30860/recycle

Here is the documentation from recycle /?

Version 3.00, Frank P. Westlake, Mar 15 2009.
Send files to, restore files from, rename, delete, and list files in, 
and empty the Recycle Bin.

RECYCLE [OPTIONS] [FILE or FILES  [NEW FILENAME]]

OPTIONS:
  /D    Delete an item from the Recycle Bin (Windows NT and later).
  /E    Empty all recycle bins (/E) or an individual bin (i.e. /E:D).
  /F    Force recycle of read-only files. Default is to skip.
  /H /? Print command line usage information.
  /L    List contents of recycle bins.
  /N    Non-Unicode output to files and pipes. Default is Unicode.
  /O    Overwrite files if they already exist. Default is to skip the file.
  /P    If recycling, prompt the user to recycle each file. If 
undeleting, prompt the user to overwrite existing files. Default is to
        skip the file if one exists at the location.
  /R    Rename a file in the Recycle Bin. Specify current name and full 
path for new name (Windows NT and later).
  /Q    Query individual drives (i.e. /Q:C) or all drives individually (/Q).
  /U    Undelete files from the Recycle Bin. A new drive:\path\name may 
be specified.

It is important that full paths be specified for the new name when 
renaming and when undeleting to a new location. Rename operations
write the new filename to a Recycle Bin control file.

EXAMPLES:
Recycle all files and folders in C:\TEMP:
   RECYCLE C:\TEMP\*

List all DOC files which were recycled from any directory on the C: drive:
   RECYCLE /L C:\*.DOC

Restore all DOC files which were recycled from any directory on the C: 
drive:
   RECYCLE /U C:\*.DOC

Restore C:\temp\junk.txt to C:\docs\resume.txt:
   RECYCLE /U "C:\temp\junk.txt" "C:\docs\resume.txt"

Rename in place C:\etc\config.cfg to C:\archive\config.2007.cfg:
   RECYCLE /R "C:\etc\config.cfg" "C:\archive\config.2007.cfg"

Obviously you would need to use something like RunShell() with it.

Hope this helps... Jonathan

jonathan.leeming@familycentre.org
Edmonton, Alberta, Canada
Itai Ben-ArtziRe: Erase and FErase
on Fri, 26 Jun 2020 20:27:34 -0700
Thanks!  I am going to try it.
-Itai
Jim LeeRe: Erase and FErase
on Fri, 26 Jun 2020 21:50:42 +0200
hi,

> Both, Erase and FErase permanently and irreversibly delete a file.  Is
> there a command or parameter that move a file to the Recycle Bin so a
> user may restore it?

use ShFileOperation to copy, move, rename or deleted files like Explorer.




SHFILEOPERATION.zip
Itai Ben-ArtziRe: Erase and FErase
on Fri, 26 Jun 2020 20:28:17 -0700
Thank you, jim!  I am going to try it.
-Itai
Ingo Steinbuechel Re: Erase and FErase
on Sat, 27 Jun 2020 10:57:52 +0200
Hi Itai,

Am 26.06.20 um 08:54 wrote Itai Ben-Artzi:

> Is there a command or parameter that move a file to the Recycle Bin so a
> user may restore it?

as you might know deleting to the Recycle Bin is nothing else than just
moving the file to the folder $Recycle.Bin. So why don't you just do
this in xBase?

HTH
Regards Ingo
Jonathan LeemingRe: Erase and FErase
on Sat, 27 Jun 2020 08:48:29 -0600
On 6/27/2020 2:57 AM, Ingo Steinbuechel wrote:
> Hi Itai,
> 
> Am 26.06.20 um 08:54 wrote Itai Ben-Artzi:
> 
>> Is there a command or parameter that move a file to the Recycle Bin so a
>> user may restore it?
> 
> as you might know deleting to the Recycle Bin is nothing else than just
> moving the file to the folder $Recycle.Bin. So why don't you just do
> this in xBase?
> 
> HTH
> Regards Ingo
Hi Ingo,

My first thought when reading your post was "OK... That's a simple 
solution!" however thinking about it I wondered how the metadata 
associated with a deleted file would get updated in the recycle bin 
(such as deletion date & time as well as restore path) if one simple 
"moved" the file.  I was thinking that for the move one is actually 
using "COPY (cSource) TO (cDestination)" followed by "FERASE(cSource)". 
Is this what you are suggesting?  and if so how does the restore path 
get updated.

Am I correct in understanding what you are suggesting and if so do you 
actually do something like this.  For some reason I thought $Recycle.bin 
was a pseudo reference to the actual folder???

Just curious... Thanks... Jonathan

jonathan.leeming@familycentre.org
Edmonton, Alberta, Canada
Andreas Gehrs-Pahl
Re: Erase and FErase
on Sat, 27 Jun 2020 13:05:08 -0400
Ingo,

>>as you might know deleting to the Recycle Bin is nothing else than just
>>moving the file to the folder $Recycle.Bin. So why don't you just do
>>this in xBase?

Actually, there are separate folders/directories for each user in the 
$Recycle.bin folder in the form of a security identifier (SID), starting 
with "S-1-5-21-", followed by the domain and object identifiers. Actually, 
the "21" belongs to the domain identifier, and there could also be others, 
like "S-1-5-18-", etc. Each user has a different SID.

In the user's directory, there will be 2 files for each deleted file, both 
with a random file name and the original file extension. The two file names 
start with a "$" and are identical with the exception of the second 
character, which is either "I" or "R".

The index file, starting with "$I", is a binary file that contains all the 
information about the deleted file, such as the original path and file name 
(in UTF16 format), the size and date and time it was deleted. The other 
file, starting with "$R", is the original file, just renamed.

So, even though you could manually move a file into the (correct sub-folder 
in the) $Recycle.bin, you also need to create the corresponding index file.

Jonathan,

>Am I correct in understanding what you are suggesting and if so do you 
>actually do something like this. For some reason I thought $Recycle.bin 
>was a pseudo reference to the actual folder???

The Windows OS creates a $Recycle.bin folder on each hard drive and will 
also create subdirectories for each user. Only Admins have access to other 
user's directories and the OS will automatically use the current user's 
subdirectory. The folder has different names in older Windows versions, like 
"C:\recycled" in Windows 98 and "C:\recycler" in Windows 2K, NT, XP. The 
file format of the index file (starting with "$I") that contains the meta 
data about the deleted file has also changed in Windows 10 and was a fixed 
length (544 bytes) in previous versions of windows.

In summary, using the Windows Shell API (or an external program that uses 
it) for deleting files into the Recycle bin would be the simplest option.

Hope that helps,

Andreas

Andreas Gehrs-Pahl
Absolute Software, LLC

phone: (989) 723-9927
email: Andreas@AbsoluteSoftwareLLC.com
web:   http://www.AbsoluteSoftwareLLC.com
[L]:   https://www.LinkedIn.com/in/AndreasGehrsPahl
[F]:   https://www.FaceBook.com/AbsoluteSoftwareLLC
Jim LeeRe: Erase and FErase
on Sat, 27 Jun 2020 20:58:34 +0200
hi,

> In summary, using the Windows Shell API (or an external program that uses
> it) for deleting files into the Recycle bin would be the simplest option.

is there any pure Xbase++ Version for this ?
Itai Ben-ArtziRe: Erase and FErase
on Mon, 29 Jun 2020 23:27:09 -0700
IMO, there should be one.  The recycle bin is a bit more complex then
just moving a file.  It seems the Windows' API is the way to go.  It
would be nice if Alaska create a wrapper for this function.
-Itai