How to make a windows batch file (.bat) delete itself while running?
[Solution]
Put the following content at the end of the (.bat) file.
-----------------------------------------------------
call :deleteSelf&exit /b
:deleteSelf
start /b "" cmd /c del "%~f0"&exit /b
-----------------------------------------------------
For example:
Here the copy_run.bat file content:
-----------------------------------------------------
copy file1.txt file1_copy.txt
call :deleteSelf&exit /b
:deleteSelf
start /b "" cmd /c del "%~f0"&exit /b
-----------------------------------------------------
After the execution of copy_run.bat file, the file (copy_run.bat) itself will eventually be deleted.
[Reference]
http://stackoverflow.com/questions/20329355/how-to-make-a-batch-file-delete-itself