Is there any way that a running process can delete its own executable?
For example, I make a console application (single exe) and after doing some tasks it somehow deletes the exe file.
I have to send a single file to someone. And I want it deleted after it does its intended task.
Is there anyway to do it in Windows
The Self-Deleting Batch File methodWhen the execuable has been deleted, the batch file then deletes itself. The executable needs to spawn off the batch file using CreateProcess , and then should exit immediately.
Reasons for EXE Files Loss The most apparent reason for the issue “lost EXE file” is antivirus settings or virus or malware infection. Most of the viruses or malware are delivered through executable files, and the antivirus programs always make most of the executable files suspicious and block or even delete them.
EXE files are a Windows-specific executable file format. When a user or other event triggers an executable file, the computer runs the code that the file contains. Executable files contain binary machine code that has been compiled from source code.
Double-click the executable file to run FileASSASIN. Click the “Browse” button to find files to delete. After selecting a file to delete, FileASSASIN will provide you with several options. Select the “Delete” option if you want to erase the file.
One way to do this is to use the MoveFileEx function with the MOVEFILE_DELAY_UNTIL_REBOOT
flag and a NULL
destination. According to the documentation, this:
registers the lpExistingFileName file to be deleted when the system restarts. If lpExistingFileName refers to a directory, the system removes the directory at restart only if the directory is empty.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With