How to make a batch file delete itself?

前端 未结 9 965
遇见更好的自我
遇见更好的自我 2020-11-28 06:07

Is it possible to make a batch file delete itself?

I have tried to make it execute another file to delete it but this did not work.

Does any one know how I cou

9条回答
  •  甜味超标
    2020-11-28 06:32

    you can set the delay to avoid race conditions, here is 15 seconds :

    START /B CMD.EXE /D /C "PING.EXE -n 15 127.0.0.1 && DEL prova.bat"
    

    NOTES

    • CMD.EXE /D is mandatory to avoid execution of auto-run crap-ware
    • PING and DEL must be executed syncronous, so surrounded by quotes
    • I let to the users how to pass the batch name using "%~f0"

提交回复
热议问题