Remove the file after starting it

Hey, I'm looking for a way to remove the file after you've started it, I've tried via TerminateProcess and then forced ALL_ACCESS (since the file is in use when you run it) and then try remove the file but that doesn't work for the file you're "currently" using.

So how do you remove the file you're currently using (.exe)?
If you can give a example/snippet code, do so.

Thanks in advance.
Last edited on
Don't know what you are talking about. Sorry can't help you.
Also not sure, but might try to help anyway:
If you're talking about deleting a file that the program is using (like a data file being read into the program), there is no way in just C++ to delete files, only to create them.
To delete files you would need to use OS-specific code.

For a program to be able to delete its own executable file, you would also having to use platform-specific code libraries, so I would suggest using google, this seems promising http://stackoverflow.com/questions/3457040/how-to-write-a-program-in-c-such-that-it-will-delete-itself-after-execution
novellof: Simply: start .exe and then remove .exe.
Thanks all! Especially the latest link, solved it.
Topic archived. No new replies allowed.