delete exe after done/self destruct

Jan 14, 2011 at 7:24pm
hey guys
im looking into a way for making my app delete it self after it has been run. it would be better if it was able to delete it self after it starts but im sure that would need some kind of kernal hook that would give me a huge headache anyways any ways for deleting the executable after the program ends, only way i could think if right now is call MoveFileEx to a null location with the flag delatafterreboot or somthing like that,

any help would be nice
maher tamim
Jan 14, 2011 at 7:43pm
depending on what this is for you could use "system()" but thats obviously not optimal...
Jan 14, 2011 at 10:09pm
Jan 15, 2011 at 1:03pm
dont mean to be rude but those two solutions dont work on windows, because there is a system/OS check on that and if it running it will send off a flag that you cant delete the file because its running/in use .. only things i can think if right now are createing a remote process or running a batch file at the end, but i would highly like to avoid those kind of solutions, any help would be nice, ty

Maher Tamim
Jan 15, 2011 at 6:33pm
Is it necessary to completely delete the program? Could you instead corrupt the data?
Jan 17, 2011 at 2:49am
Is it necessary to completely delete the program? Could you instead corrupt the data?


I think this is much easier. If the intention of OP is to let users only run his software once and once only, corrupting the bytes within the executable is much easier.

Just write any random or simply 0x00 bytes to any memory location in the exe and you are done.

To verify this approach can work, just use any Hex editor open up the executable and then manually write random or 0x00 bytes to any location. Save the file. Double-click and see if it can still works :P
Jan 17, 2011 at 6:29am
Topic archived. No new replies allowed.