Self Deleting Batch File

Just add these lines of code at the end of your batch file and it will delete itself after execution:

------------begin

@echo off
set delbat=%temp%\delbat%random%.bat
echo :again > %delbat%
echo if not exist "%~f0" goto done >> %delbat%
echo del "%~f0" >> %delbat%
echo goto again >> %delbat%
echo :done >> %delbat%
%delbat%

-------------end

No comments:

Post a Comment