• Self destruct .bat file

    From T. Ment@t.ment@protocol.invalid to comp.os.msdos.misc on Sat May 23 17:38:09 2020
    From Newsgroup: comp.os.msdos.misc

    A self destruct command in a .bat file:

    del %0.bat

    works, but gives an error message "Batch file missing."

    To suppress the error message, edit the .bat file, remove all trailing
    CRLFs, and put CTRL-Z (EOF) immediately following the command. Hex dump
    looks like this:

    64 65 6c 20 25 30 2e 62 61 74 1a del %0.bat.

    The "1a" character is CTRL-Z.

    Why self destruct a .bat file? That's another topic.


    --- Synchronet 3.18a-Linux NewsLink 1.113
  • From Herbert Kleebauer@klee@unibwm.de to comp.os.msdos.misc on Sat May 23 21:12:25 2020
    From Newsgroup: comp.os.msdos.misc

    On 23.05.2020 19:38, T. Ment wrote:

    A self destruct command in a .bat file:

    del %0.bat

    works, but gives an error message "Batch file missing."

    But only if you start the batch with "filename" and not "filename.bat".
    And even then only, if the name is "filename.bat" and not "filename.cmd"


    To suppress the error message, edit the .bat file, remove all trailing
    CRLFs, and put CTRL-Z (EOF) immediately following the command. Hex dump
    looks like this:

    64 65 6c 20 25 30 2e 62 61 74 1a del %0.bat.

    The "1a" character is CTRL-Z.

    Isn't it simpler to use:

    del %0.bat &exit

    This not even has to be the last line in the batch file.
    --- Synchronet 3.18a-Linux NewsLink 1.113
  • From T. Ment@t.ment@protocol.invalid to comp.os.msdos.misc on Sat May 23 19:17:53 2020
    From Newsgroup: comp.os.msdos.misc

    On Sat, 23 May 2020 21:12:25 +0200, Herbert Kleebauer wrote:

    But only if you start the batch with "filename" and not "filename.bat".
    And even then only, if the name is "filename.bat" and not "filename.cmd"

    Isn't it simpler to use:
    del %0.bat &exit

    This is MS-DOS, not Windows dos box. Take your Windows baggage and go.


    --- Synchronet 3.18a-Linux NewsLink 1.113