You are not logged in.
Pages: 1
I have been working a a batch file that will securely delete file and it is now complete however I would like to make it like a cmd command perhaps by turning it in to a hybrid but I don't know how to do this here's the code.
@echo off
title SDEL - secure, speedy deltetion
:again
cls
echo SDEL - Secure delete program
echo.
echo F - Delete only one file
echo D - Delete all files in this directory (folder)
echo E - Exit this batch
echo.
set /p o=Please select a option:
if /i %o%==F goto file
if %o%==d goto folder
if %o%==D goto folder
if /i %o%==E goto x
goto again
rem Delete only one file
:file
set /p f=Enter path of file including extension:
If exist %f% goto del else goto f && echo path invalid
:del
set file=%f%
FOR /f %%i IN ("%file%") DO (
set filepath=%%~pi
)
cd /d %filepath%
type nul> %f%
ren %f% sdel%random%.sdel
pause>WARNING- This file will delete all files named *.sdel in %filepath% press any key to continue...
del *.sdel
goto x
rem Delete all files in this directory (folder)
:folder
set /p d=enter path of folder to delete:
cd /d %d%
for %%a in (*.*) do type nul > %%a
for %%a in (*.*) do ren sdel%random%.sdel %%a
for %%a in (*.*) do del *.sdel %%a
goto :x
rem Exit this batch
:x
echo.
echo coded by Batchcc
echo Special thanks to Trebor68 for helping.
echo http://www.dostips.com/forum/viewtopic.php?p=43862#p43862
echo this file may be redistributed but do NOT remove the credits.
echo You are now exiting this batch file, deletion complete...
pause
goto :eof
Can I turn this into a file that I can just run a command for it to work like sdel filePath\file.extension /f or /d ?
Thanks.
Offline
If you're trying to be able to run it from any directory on your computer, all you have to do is put the script in one of the directories listed in your system PATH.
Open the command prompt, type echo %PATH%, pick one of the directories listed, and put the script in there. You will then be able to run the script without needing to type the full path.
Offline
See here for details about using command line arguments:
cmd | *sh | ruby | chef
Offline
i was looking for something like this but it doesnt work
@if (@X)==(@Y) @end /* JScript comment
@echo off
setlocal
for /f "tokens=* delims=" %%v in ('dir /b /s /a:-d /o:-n "%SystemRoot%\Microsoft.NET\Framework\*jsc.exe"') do (
set "jsc=%%v"
)
if not exist "%~n0.exe" (
"%jsc%" /nologo /out:"%~n0.exe" "%~dpsfnx0"
)
%~n0.exe %*
endlocal & exit /b %errorlevel%
*/
import System;
var arguments:String[] = Environment.GetCommandLineArgs();
var newLine = false;
var output = "";
var foregroundColor = Console.ForegroundColor;
var backgroundColor = Console.BackgroundColor;
var evaluate = false;
var currentBackground=Console.BackgroundColor;
var currentForeground=Console.ForegroundColor;
//http://stackoverflow.com/a/24294348/388389
var jsEscapes = {
'n': '\n',
'r': '\r',
't': '\t',
'f': '\f',
'v': '\v',
'b': '\b'
};
function decodeJsEscape(_, hex0, hex1, octal, other) {
var hex = hex0 || hex1;
if (hex) { return String.fromCharCode(parseInt(hex, 16)); }
if (octal) { return String.fromCharCode(parseInt(octal, 8)); }
return jsEscapes[other] || other;
}
function decodeJsString(s) {
return s.replace(
// Matches an escape sequence with UTF-16 in group 1, single byte hex in group 2,
// octal in group 3, and arbitrary other single-character escapes in group 4.
/\\(?:u([0-9A-Fa-f]{4})|x([0-9A-Fa-f]{2})|([0-3][0-7]{0,2}|[4-7][0-7]?)|(.))/g,
decodeJsEscape);
}
function printHelp( ) {
print( arguments[0] + " [path] [file name + extension] -d or -f" );
print( " " );
print( " -d Deletes all files in a directory " );
print( " -f Deletes one specifies file ");
print( "" );
}
if ( arguments.length == 1 || arguments[1].toLowerCase() == "-help" || arguments[1].toLowerCase() == "-help" ) {
printHelp();
Environment.Exit(0);
}
for (var arg = 0; arg < arguments.length; ++arg) {
if ( arguments[arg].toLowerCase() == "-f" ) {
evaluate=true;
}
if ( arguments[arg].toLowerCase() == "-d" ) {
output=arguments[arg+1];
}
}
Offline
But why are you trying to turn it into a hybrid script? I don't see a single good reason to do so.
Offline
Shadow thief I am unable to call sdel from the command line using the command
Sdel H:\folder /d
Or
Sdel H:\file /f
Am I calling it wrong?
Offline
It's not that you're calling it wrong, it's that your code currently doesn't support parameters. Read this: http://ss64.com/nt/syntax-args.html
Offline
Pages: 1