简体   繁体   中英

cannot echo self delete command in another batch file

i have a file named as new.bat.

  1. using echo creates another "1.bat" batch file and writes code in it
  2. self delete command is also added in 1.bat
  3. 1.bat is run by start /MIN 1.bat

my main file (new.bat) file is getting deleted and cmd process exit, leaving behind 1.bat which i want to delete.

i know del "%~f0" & exit with this command self batch file is deleted, but wrong batch file is deleted

here are my below files

New.bat

echo echo 1 >>1.bat
echo del "%~f0" & exit >>1.bat
start /MIN 1.bat

pl Help

Try either:

Echo Echo 1 >>1.bat
Echo Del "%%~f0" ^& Exit >>1.bat
Start /MIN 1.bat

Or:

(   Echo Echo 1
    Echo Del "%%~f0" ^& Exit
)>1.bat
Start /MIN 1.bat

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM