Thursday, December 4, 2008

Can a Program commit suiside?

Yes. A proram can delete itself after running.
You can verify this by running the exe inside this zip file.

Thanks to Alex for the solution.Great thought.
Here is the C# code

Process.Start("cmd.exe", "/C choice /C Y /N /D Y /T .5 & Del " + Application.ExecutablePath);
Application.Exit();//This is needed in the case of Windows application.

Some technical things.
The choice is playing major role here.It delays the deletion by .5 secs .The delay gives enouhg time for the program to get removed from the memory. Else it won't get deleted.
If you need more details about choice open a command prompt then type 'choice /?'

1 comment:

Blogger said...

If you need your ex-girlfriend or ex-boyfriend to come crawling back to you on their knees (no matter why you broke up) you got to watch this video
right away...

(VIDEO) Get your ex back with TEXT messages?