I am writing uninstaller.
Suppose it runs, deletes all files, and, ultimately, it must delete itself. But the process keeps the exe file. How to be?
MoveFileEx() with the MOVEFILE_DELAY_UNTIL_REBOOT flag. Then your file will be deleted after a reboot. And it will not be necessary to dance with batch file.
Just in case, the option via CMD ( ping 127.0.0.1 -n 5 > nul command is needed for a delay of five seconds):
Process.Start("cmd.exe", "/C ping 127.0.0.1 -n 5 > nul & del " + Application.ExecutablePath); Application.Exit(); Also, as an option, you can create and run a simple bat-file - they can delete themselves without problems.
Source: https://ru.stackoverflow.com/questions/573565/
All Articles