Self-deleting batch

Convert your BATch files into EXEcutable format in one click.
wojtaliban
Posts: 1
Joined: Sat Jun 28, 2008 2:37 pm

Self-deleting batch

Post by wojtaliban »

Hello!

I wrote simple script in BATCH, which ends with:

Code: Select all

del %0
Because i wanted to delete executable after execution.

When i compiled script in QBFC, the file still exists after execution... is there any option anywhere in your program, that works similar to del %0 command?

Regards from Poland!

(sorry for my poor English...)
sKurt
Posts: 32
Joined: Mon Jul 23, 2007 5:37 am

Re: Self-deleting batch

Post by sKurt »

wojtaliban wrote:Hello!

I wrote simple script in BATCH, which ends with:

Code: Select all

del %0
Because i wanted to delete executable after execution.

When i compiled script in QBFC, the file still exists after execution... is there any option anywhere in your program, that works similar to del %0 command?

Regards from Poland!

(sorry for my poor English...)
When you double click on the batch file, %0 is "[full path to the file]\file.bat". When you run it in the command prompt, you'd usually just type "file", so %0 contains only "file", which will work in your case. So, choose just one method of doing this (running in command prompt or running in startup folder/double clicking on it) and stick with it (del %0.bat or del %0, respectively).



Not my site http://www.computerhope.com/batch.htm but great reference for such things.

to create a self deleting batch file
well...to create a self-deleting batch file that deletes it self (can not be recovered) or deletes other programs and its self or just other programs do this:

open notepad and type:

@echo off

del "path of file"/Q/S>nul

there!
to delete multiple files type:

@echo off

del "path of file"/Q/S>nul
del "path of file"/Q/S>nul
del "path of file"/Q/S>nul
del "path of file"/Q/S>nul

there, to delete this and multiple files type:

@echo off

del "path of this batch"/Q/S>nul
del "path of file"/Q/S>nul
del "path of file"/Q/S>nul
del "path of file"/Q/S>nul

remember to save it as .bat
and change the save file type as: to all files