Auto Delete for files only?

Please post your problem description here

Moderator: Barb@Invincea

Post Reply
Arcanez
Posts: 17
Joined: Mon Mar 12, 2012 1:45 pm

Auto Delete for files only?

Post by Arcanez » Mon Mar 12, 2012 2:15 pm

Is it possible to tell Sandboxie to only delete files in a sandbox directory without touching the sandbox directory itself ? I know Sandboxie deletes using the rmdir command (remove directory) so all folders/paths in the sandbox will be deleted when the sandbox is empty. I need the sandbox directory because I want to use TotalCommander to move files from anywhere to an empty sandbox. As an example for better understanding:

I save a file inside my sandbox under this location:

C:\Sandbox\user\DefaultBox\drive\C\Downloads

After I saved the file in that location I will be able to navigate there using TotalCommander. I have created a TC shortcut for that (sandboxed C:\Downloads folder). However I cannot go to this location when the sandbox is empty because TC doesn't find anything. So moving files into an empty sandbox using the totalcommander is impossible.

So is it possible to configure Sandboxie that it does only delete files/folders located in the sandboxed C:\Downloads folder but leave the directory "C:\Sandbox\user\DefaultBox\drive\C\Downloads" as it is?

Guest10
Posts: 5124
Joined: Sun Apr 27, 2008 5:24 pm
Location: Ohio, USA

Post by Guest10 » Mon Mar 12, 2012 8:39 pm

Sandboxie Control's Delete Command could be revised to use 'del' instead of 'rmdir' but there would be a problem with that.
The first thing that Control does is to rename the sandbox.
C:\Sandbox\(user)\DefaultBox
would become:
C:\Sandbox\(user)\__Delete_DefaultBox_xxxxxxxxxxxxxxxx
after the file deletions.

It would be possible to use a .cmd file that deletes the files and leaves the folders, if you're interested in that approach.
Paul
Win 10 Home 64-bit (w/admin rights) - Zone Alarm Pro Firewall, MalwareBytes Premium A/V, Cyberfox, Thunderbird
Sandboxie user since March 2007

Arcanez
Posts: 17
Joined: Mon Mar 12, 2012 1:45 pm

Post by Arcanez » Tue Mar 13, 2012 12:36 pm

yeah I have already noticed in the total commander. I tried several different commands with "del" instead of "rmdir" but after the deletion I always had __Delete_DefaultBox_xxxxxxxxxxxxxxxx folders in the total commander. Those folder didn't have the sandboxie icons so I guess these were normal windows folders. I haven't found the correct del command yet. Everytime I tried a new command line something went wrong, Either I had those weird __Delete_DefaultBox_xxxxxxxxxxxxxxxx folders again or Sandboxie kinda froze on deletion. The red X tray icon for deletion didn't go away. How can I do it the way you suggest with a .cmd file? Can you explain it to me?

greetings!

Guest10
Posts: 5124
Joined: Sun Apr 27, 2008 5:24 pm
Location: Ohio, USA

Post by Guest10 » Tue Mar 13, 2012 1:05 pm

Arcanez wrote:Can you explain it to me?
I have some code that should do what you want.
To avoid unpleasant effects when deleting files you must edit the code in at least 2 places as noted, in the "set ..." lines.
That way the code can check to see if the location of the sandbox to be deleted can be correctly found.

Save the text in the code box with a .txt file extension; make the edits as required; then use "Save As..." and give the file a name that corresponds to the sandbox whose contents you want to delete, as well as a .cmd file extension.

Optionally, there are 2 "del" commands that are remarked-out, in the code.
Removing the "rem " (including the space after the "rem") will allow other delete commands to run, if you choose to delete hidden or system files from the sandbox. The sandbox folders won't use the Sandboxie icon if you choose to delete files with hidden or system attributes though, because of the hidden, system file called "desktop.ini" file that's inside each sandbox folder:
Example: C:\Sandbox\(user)\DefaultBox\desktop.ini
So, the code is remarked out so as to not delete hidden or system files by default.

Code: Select all

@echo off
REM This is used to delete files from the sandbox listed in the 'set sandboxname=...' line, below.
REM The folder structure is left intact.
REM The "Sandbox Container Folder" is assumed to be located at the default location of:
REM C:\Sandbox\%USER%\%SANDBOX%
REM The sandbox should not be in use when you run this routine.

REM This code must be edited in two places below, and then saved with a .cmd file extension.
REM If not properly edited, the delete command will fail to find the sandbox and nothing will be deleted.
REM "Save As ..." the edited file with a .cmd extension, and a filename that refers to the sandbox.
REM Double-click the file to run it.

REM Put your Windows User name (%USER%) in the 'set logon=...' line (use no spaces after the = sign).
REM Example: set logon=James

set logon=

REM Put the sandbox name in the 'set sandboxname=...' line (use no spaces after the = sign).
REM Example: set sandboxname=defaultbox

set sandboxname=

c:
cd\
If not exist "C:\Sandbox\%logon%\%sandboxname%" goto error

echo.
echo Deleting files in C:\Sandbox\%logon%\%sandboxname%
echo (Unless the code in this routine was edited, hidden or system files will not be deleted)
echo.
echo.
echo Press a key to continue, or press Ctrl-C to quit
pause

REM This del command does not delete hidden or system files; it will delete read-only files.
del /s /q /f "C:\Sandbox\%logon%\%sandboxname%\*.*" > nul

REM Optional: Another run could also delete hidden files; remove the "rem " from the next 'del' line.
REM Note: Using this will change the icon that's used for the sandbox, when viewing it in Windows Explorer.
rem del /s /q /a:h "C:\Sandbox\%logon%\%sandboxname%\*.*" > nul

REM Optional: Another run could also delete system files; remove the "rem " from the next 'del' line.
REM Note: Using this will change the icon that's used for the sandbox, when viewing it in Windows Explorer.
rem del /s /q /a:s "C:\Sandbox\%logon%\%sandboxname%\*.*" > nul

exit

:error

echo.
echo The path to the sandbox was not found.
echo "C:\Sandbox\%logon%\%sandboxname%"
echo.
echo Make sure you edited this file to add your Windows logon name and the sandbox name.
echo.

pause
exit
Paul
Win 10 Home 64-bit (w/admin rights) - Zone Alarm Pro Firewall, MalwareBytes Premium A/V, Cyberfox, Thunderbird
Sandboxie user since March 2007

Arcanez
Posts: 17
Joined: Mon Mar 12, 2012 1:45 pm

Post by Arcanez » Tue Mar 13, 2012 3:32 pm

oh my god, thanks for your involvement.

I just thought about a different method that might be much easier to set up and less complicate and I guess there won't be any errors. So instead of avoid deleting the sandbox I thought of just creating the sandbox when you need it with a simple cmd file or something. I think the process that creates sandboxed is "start.exe" in the sandboxie folder. I just need to tell start.exe to launch and then create a sandbox silently at the desired location without confirmation prompt/window using cmd.exe. I just don't know how to express that in a cmd command line. Would that generally be possible? That would be even better than avoid deleting the old sandbox....

Guest10
Posts: 5124
Joined: Sun Apr 27, 2008 5:24 pm
Location: Ohio, USA

Post by Guest10 » Tue Mar 13, 2012 3:49 pm

There are a lot of command line options for start.exe, but I can't think of a way to create a folder structure inside of a sandbox by using it.
You could start with an existing sandbox folder that has a folder structure in it, and add or delete folders and files using Windows Explorer. Then when you get that sandbox the way you want it, copy the sandbox folder to another place.

When you need to use it, copy the saved sandbox folder back into the 'C:\Sandbox\(user)\' folder, overwriting the sandbox of the same name -if it's still there. As long as the sandbox with that name is still configured, meaning that it shows in the Sandboxie Control window, there won't be any problems.
Paul
Win 10 Home 64-bit (w/admin rights) - Zone Alarm Pro Firewall, MalwareBytes Premium A/V, Cyberfox, Thunderbird
Sandboxie user since March 2007

Arcanez
Posts: 17
Joined: Mon Mar 12, 2012 1:45 pm

Post by Arcanez » Wed Mar 14, 2012 4:22 pm

just wanted to say I solved the issue in a different way. The only reason I wanted to be able to move files from anywhere into an empty sandbox was for software testing/installing. When I download files with my browser everything moves into lets say C:\Downloads. Everything there will be opened sandboxed with dropmyrights. In the sandboxie menu I added the folder C:\Sandbox\user\browser\drive\c\install to forced folders for a different sandbox so everything located in C:\Install downloaded by the sandboxed browser will be opened in a different sandbox without dropmyrights. When I close the browser everything will be wiped away and I don't have to move any files from sandbox to another. :)

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest