Secure Delete and Shutdown.

Utilities designed for use with Sandboxie
Post Reply
pjpj
Posts: 10
Joined: Tue Mar 11, 2014 7:46 am

Secure Delete and Shutdown.

Post by pjpj » Wed May 07, 2014 1:27 pm

I regularly see requests for this or something similar so thought I would post my simple code for people to copy and paste into notepad, edit as necessary and use. You will need to download and install the secure delete program of your choice.

As we all know, secure deleting files can take a long time and you really don't want to be sitting in front of your PC whilst it is deleting just so you can shutdown the computer. This code will do that for you. I have a shortcut link to my desktop which I use.

Tested on Windows 7 Ultimate. It may not work on all Windows OS's without slight modification to some commands.

You will need to edit the location of your secure delete program and the sandbox name on both :deleteonly and :deleteandshutdown and make sure 'Automatically Delete Sandbox' is not ticked for the appropriate sandbox in Sandboxies configuration.

A couple of small things to note, it will not delete the actual folder if you have that folder open in explorer although all the contents are deleted. A logfile is written so most errors can be seen the next time you startup, this is overwritten at each delete.

Hope it helps some of you that have been asking for something like this.

Maybe Invincea could at some point add the selection of a shutdown after deleting a sandbox or maybe a request to shutdown before the deletion process starts.

:: Program to secure delete files from a sandbox and shutdown the computer at the end.

@ECHO off

endlocal

setlocal enableextensions enabledelayedexpansion

:: Date
set dd=%date%
FOR %%A IN (%dd:/=%) DO SET dd=%%A

:: Time
set tt=%time:~0,5%
FOR %%C IN (%tt::=%) DO SET tt=%%C

echo.
echo.


:: Request from user to shutdown after delete.

set /p delbox=Would You Like To Shutdown After Deleting Sandbox. [y/n]?:
if "!delbox!"=="y" (
GOTO deleteandshutdown
) else (
GOTO deleteonly
)


:: Delete and shutdown code.

:deleteandshutdown

::Delete existing logfile.
del "delete*.txt"
echo.
@echo Delete and Shutdown >> delete_%dd%%tt%.txt
echo.

:: Request Sandboxie start.exe to terminate all programs in any sandbox.
"C:\Program Files\Sandboxie\Start.exe" /silent /terminate_all

:: Use Sdelete to secure delete the appropriate sandbox.
"C:\SDelete\sdelete.exe" -p 1 -s C:\Sandbox\Paul\Browser >> delete_%dd%%tt%.txt

:: Use Sandboxie start.exe to delete folder remenants that Sdelete is not authorised to.
"C:\Program Files\Sandboxie\Start.exe" /box:Browser /silent delete_sandbox

:: Shutdown computer.
"c:\windows\system32\shutdown.exe" -s

echo.
@echo Ta-Ra Chuck! >> delete_%dd%%tt%.txt
pause >nul
endlocal
exit

:: Delete only code.

:deleteonly

::Delete existing logfile.
del "delete*.txt"
echo.
@echo Delete Only >> delete_%dd%%tt%.txt
echo.

:: Request Sandboxie start.exe to terminate programs only in the appropriate sandbox.
"C:\Program Files\Sandboxie\Start.exe" /box:Browser /terminate

:: Use Sdelete to secure delete the appropriate sandbox.
"C:\SDelete\sdelete.exe" -p 1 -s C:\Sandbox\Paul\Browser >> delete_%dd%%tt%.txt

:: Use Sandboxie start.exe to delete folder remenants that Sdelete is not authorised to.
"C:\Program Files\Sandboxie\Start.exe" /box:Browser delete_sandbox

echo.
@echo Press Any Key
pause >nul
endlocal
exit
Regards

PJPJ

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests