process.start("cmd /c ping localhost -n 3 > nul & del filepath")
exit
Explanation :
ping localhost -n 3
Adds a slight delay before executing del filepath
. By the time it's triggered, your program has exited.
Replace process.start with whatever command your programming language uses to start programs with arguments.
Replace filepath with the path to your exe.
Replace exit with the command for terminating your program.
===
10yr anniverary edit, if this doesn't work, you must find a way to perform a "process.start" that starts a separate (external) process, not one subordinate to your original calling program: Python, Bash, C, ...... or search for a different language
Replace the search in the catch all with your programming language and you will likely find a suitable guide for this essential step. Please take care to ignore superfluous information as every question may come with obscure specific details that are unrelated to you.