system commands. deletion of file after program terminates
Is there a way to delete an executable after terminating itself?
I want to delete my program after it has finished running.
We are required to write a stack that when overloaded it restarts your machine and on reboot it reloads the data and deletes itself out of the startup folder? I keep getting access violations when trying to delete it while it is still running. Is there a command I can run to execute the delete after the program has completed running? Below is the error in the quote and also a selection from my code.
Thanks for any help this provides.
C:\Documents and Settings\All Users\Start Menu\Programs\Startup\Stack Array.exe
Access is denied.
system("del \"C:\\Documents and Settings\\All Users\\Start Menu\\Programs\\Startup\\Stack Array.exe\"");
cout<<"Press any key"<<endl;